Jul 23
Multiline string literals in c#
icon1 sam sinfield | icon2 CSharp | icon4 07 23rd, 2007| icon33 Comments »

Having programmed in Python for the last year and now moving over to csharp, one of the things that irritated me about csharp was how it handled strings.

For example, in python, assigning a comma seperated object representation to a string variable would simply be:

var = “%s,%s,%s”%(obj1,ob2,ob3)

whereas in c#, it would be:

var = obj1.ToString()+”,”+obj2.ToString()+”,”+obj3.ToString()

This still pisses me off and I still haven’t found a more elegant way to do it and it’s only basic stuff.

The other is multiline strings.

eg, a multiline in python would simply be

var = “”"this is

a

multiline string”"”

in c#, until now, I’ve been using the longwinded way of:

var = “this is \n”

+”a \n”

+”multiline string”"
Until I’ve now discovered you can do it like:

var = @”this is
a
multiline string”

Wow, you learn something new everyday, how could I have not known this before, something so basic. I still prefer to code python and some things in c# and the .NET Framework really bug me but things are getting better

Jul 19
About me, according to Astrology
icon1 sam sinfield | icon2 Personal | icon4 07 19th, 2007| icon32 Comments »

I’m not a great believer in things like Astrology. I don’t really believe that the position of the stars when you’re born determines the person you are and maps out your life for you. I’m not saying it’s definitely not true, just that I find it unlikely, so don’t normally bother reading horoscopes etc. However, I saw an astrological profile on someone else’s blog and thought I’d have ago for a bit of fun. It’s actually quite accurate, of course there’s some bits that I strongly disagree with, which I have highlighted in red, but I’d agree with about 85% of it. So here it is, me, according to astrolabe
Name: samantha carol sinfield
March 7 1975
4:30 AM Time Zone is UT
colwyn bay, UK

Rising Sign is in 12 Degrees Capricorn
You are practical and reserved but very ambitious. An achiever and a hard worker, you respect success. Older looking and very serious as a youth, things lighten up and you relax more as you mature. You have a serious view of the world as being a difficult place to be in. Very envious of those who seem to have an easier life than you have, relaxation and play do not come easily. It is important that you had abundant parental support as a child so that you do not feel lonely and isolated as an adult. Generally, you have a good, earthy sense of humor that can carry you through when times really do get tough. You are purposeful, self-willed, industrious, realistic and responsible.

Sun is in 15 Degrees Pisces.
Extremely sensitive and emotional, you absorb the emotions of others (whether positive or negative) like a sponge. Emotionally vulnerable, you are easily upset and tend to cry readily. You are at your best when you can structure your environment in such a way that you are surrounded by positive, upbeat people. You are very helpful and understanding of the needs of others. Indeed, at times this can be a disadvantage, because you can be a sucker for anyone who needs help. Shy, dreamy, romantic in nature, you delight in retreating into your private fantasy world. Just be careful that you do not get lost in it! Trust your intuitions — you may be quite psychic.

Moon is in 12 Degrees Capricorn.
You are serious and shy and very uncomfortable in those situations where spontaneous and exuberant emotional reactions seem called for. An achiever, you prefer doing practical, worthwhile things that produce tangible results. You need role models to respect, love and emulate. You tend to feel that you’re a failure unless you get an important and highly respected position in life. Don’t be so hard on yourself! For you, practical needs always win out over emotional considerations. Remember that you too have the right to comfort, security and love. Dutiful and patient, when you make an emotional commitment, you sign on for the long haul — your love is long- enduring.

Mercury is in 18 Degrees Aquarius.
You tend to be very opinionated — you have strongly felt notions about things and are quite vocal about expressing and defending them. Yet you are also an original thinker — you enjoy shocking others with your offbeat, original thoughts. You appreciate and need mental and intellectual stimulation. Your judgment is usually fair and impartial — you can be a good critic because you can remain objective and unemotional about most things.

Venus is in 14 Degrees Aries.
You are a very affectionate person but you hate to be tied down. You are more than willing to be the aggressor in initiating new relationships. Indeed, once you have set your sights on someone, you tend to pursue him or her ardently and passionately. But you do demand your own way in a relationship. Try to give in to your partner’s needs and desires once in a while.

Mars is in 02 Degrees Aquarius.
Your ideas and opinions are usually inventive and original, but sometimes they are merely eccentric and offbeat. You are altruistic — you will work hard for the attainment of group goals, as long as they meet your high standards. You tend to resent traditional authority figures because you think that your ideas are better thought out and more valuable than theirs. Very idealistic, you are a rebel WITH a cause!

Jupiter is in 27 Degrees Pisces.
You are at your best when you give of yourself and what you have — try to avoid being a martyr about it, though. You’re a true idealist, but you must learn not to be upset when life does not cooperate with the way you think things should be. Very concerned with spiritual truth and growth, when you practice what you preach, you make an excellent role model for others. You are so devoted to altruistic ventures and concerns that you tire easily at times. It then becomes necessary for you to go off by yourself to recharge your batteries.

Saturn is in 11 Degrees Cancer.
The most important issue for you is emotional security. You have a deep and gnawing fear that those on whom you depend for emotional support will prove to be unreliable in the long run. When you are unloved and insecure, you distrust others and tend to feel isolated and lonely. Very cool, detached and objective, you can be counted on — in situations that are inherently stressful or full of tension — not to lose your self- control. That is a great and welcome gift at such times.

Uranus is in 02 Degrees Scorpio.
You, and your peer group, demand to confront life at its deepest and most meaningful levels. Very compulsive and obsessive in your approach to everything, you will avoid anything that is casual or superficial, especially when it comes to relationships. You will seek out and explore new methods of healing as well as different ways to deal with deep-seated emotional problems.

Neptune is in 11 Degrees Sagittarius.
You, and your entire generation, are heavily involved in investigating and idealizing foreign and exotic intellectual systems and religious philosophies. The most extreme ideals will be pursued with gusto. You will be at the forefront of humanitarian attempts to improve the lot of those who are in need of assistance. You will be comfortable with the concept of the “global village.”

Pluto is in 08 Degrees Libra.
For your entire generation, this is a time of radical changes in society’s attitude toward marriage and interpersonal relationships. There is a general fear and awe at the power inherent in making emotional or contractual commitments — they will not be entered into lightly.

N. Node is in 04 Degrees Sagittarius.
You will probably have many different contacts and acquaintances throughout your life. You’re quite gregarious by nature and your natural curiosity about others lets you take the lead in forming new relationships. You’ll form close ties with those who have similarly idealistic ideas — especially those who can stimulate you intellectually in your chosen field of interest. Your enthusiasm for learning new things may also cause you to do quite a bit of traveling. Because you probably will have many wide-ranging interests and concerns, you most likely will have contacts and connections in various parts of the country (or world).

Jul 2

Following on from previous posts (alcohol and memory loss and back to old habits), I have been researching the phenomenon of alcohol-induced black-outs. A couple of weeks ago, I proposed the theorem that the degree of memory loss is directly related to the type of alcoholic drink consumed and used myself, of course as the test subject.

After a good night out with all (most) of my colleagues from work, and having a decent meal before drinking, I spent all night drinking vodka and red bull and putting my theory to the test. I drank shit loads of vodka and red bull and can remember most of the night, to a point. It then becomes a bit sketchy after about midnight. I didn’t have complete memory loss, probably about 60% memory loss. My memory came back 100% after about 4am.

I therefore revise my theory about the type of drink directly affecting your degree of memory loss and amend it to the type of drink affects how drunk you get, and this isn’t necessarily linearly related to the percentage of alcohol in that drink. How drunk you are, and also how tired you are, are directly related to the degree of memory loss.

If you don’t want to suffer from alcohol-induced black-outs, my advice would be:

  1. prepare for a big night out several days before by getting loads of sleep and adjusting your sleep routine as much as you can so you’re used to staying up late.
  2. Have a medium sized meal before you go out, not too much though. A high carb meal is a good choice, such as pasta or rice.
  3. Drink slowly during the night, I know you’ve heard it a million times before, but you have to pace yourself and try to drink the odd soft drink. Remember, a forgotten night is a wasted night!
  4. If you think you’re approaching the black-out limit, test yourself by trying to remember what happened 15 minutes ago. If you don’t care, you’ve probably drunk too much!!
  5. If you’ve hit the black-out limit, it’s not necessarily time to go home. Bring yourself back to under the limit by drinking a couple of cans of red bull, slowly, with no vodka in, it might be difficult, but it still tastes good, especially with lots of ice.

Remember, the best nights out are ones where you are slightly drunk but still have full control over your actions and your memory. If you can’t remember the whole night, not only is it a waste of money getting to that point, it is a waste of time. That’s time out of your life. Time that you can’t get back. It really isn’t worth it!