This is like the geekiest thing ever. Love it. Embrace the geek. Embrace your inner geek.
Swapping places between two values in a computer is a bit more involved than one would first think.
A = B ;
B = A;
doesn't work since in the first line A gets the value from B and in the second B gets the value from A (which is now B) so the value for A is lost. You need a temporary storage. When swapping places in the real world,say two glasses, you simply take one in each hand and swap them. The problem is the computer only has one "hand". So you need to do something like:
C (temporary storage) = A;
A = B;
B = C;
No biggie right ? There's plenty of memory nowadays and C can be reused right after we're done.
But what if you're programming for a really tiny embedded processor like a PIC for example ? Or you have a tightly optimized Assembly loop and you have used all registers ? Memory access is sllooowwww compared to register access and can wreak havoc with performance in critical sections of the code.
Enter you new best friend: the XOR swap algorithm:
A= A xor B;
B = A xor B;
A= A xor B;
or in x86 Assembly
xor eax,ebx
xor ebx,eax
xor eax,ebx
Voila! The value of register a is now in b and vice versa and we only used 2 registers instead of 3.
My inner geek gets all misty eyed and weepy. Love it.
tisdag 28 maj 2013
Double positive
Languages are a funny thing. People often think of languages as having a 1:1 relationship with each other, for every word in one language,there's acorresponding one in the other and if you only find them the problem is solved. That's far from the case. I much enjoy the German band Rammstein.
Their lyrics are absolutely hilarious but impossible to translate. There's so much humour possible with the German language simply not possible in another.
Du (You)
Du hasst (You have)
Du hasst mich (You hate me)
Du hasst mich gefragt (You asked me)
See the meaning changes as you add words in German in a completely different way compared to English. It's not the same thing in English at all. The suspense is lost.
Another story is double negatives and positives.
A double negative in English for example becomes a positive. Not so in Russian,it's still a negative, presumably an even more negative negative. In an odd lack of symmetry a double positive does not become a negative in any language. Not one.
Yeah........right.....
Their lyrics are absolutely hilarious but impossible to translate. There's so much humour possible with the German language simply not possible in another.
Du (You)
Du hasst (You have)
Du hasst mich (You hate me)
Du hasst mich gefragt (You asked me)
See the meaning changes as you add words in German in a completely different way compared to English. It's not the same thing in English at all. The suspense is lost.
Another story is double negatives and positives.
A double negative in English for example becomes a positive. Not so in Russian,it's still a negative, presumably an even more negative negative. In an odd lack of symmetry a double positive does not become a negative in any language. Not one.
Yeah........right.....
söndag 26 maj 2013
Notes from the lighter side
And now for something completely different.
Wow,my hero, Vince Clarke. The reason i got into synthesizers.
He sure is one seriously good looking man and one seriously ugly woman.
And that's all i have to say about that. Life's a box of chocolates. Yeah.
Who am i ? And who are you ? Really ?
I used to think not knowing who you are was complete nonsense. How could you not ? You are yourself.
How does it manifest itself ? You don't know if you like apples all of a sudden ? That's just ridiculous. Or so i thought.
Turns out there's this thing called serotonin. It's a neurotransmitter that's thought to be responsible for feelings of happiness and well being. Great right ? Well if you have to little of it,you get depressed and life sucks and there's no point in doing anything. Yeah but that's a disease and there's pills for it. Yes there are, they're called selective serotonin reuptake inhibitors,Jesus Christ that's a hard sentence,why don't we just call them "happy pills". Yeah people refer to them as that or Prozac which is a popular brand of SSRIs.
They're absolutely great,turns out though they can be a bit too good. You can become manic from them. That sounds a bit scary however i guarantee you it is not! It's the best thing in the world! You're smarter and more creative than you've ever been in your whole life and who wouldn't want that ? It's the best high in the world,you don't want to get high/drunk (choose your poison) you're perfect as you are,why change that ?
You are as happy as a pig in shit and brilliant ideas doesn't seem to stop, appearing to you seemingly out of thin air.
Ok so there are some downsides. You get so excited you become a bit reckless. And it's really hard to focus because you have so many great ideas at once. Just as you're on the verge on solving unified field theory,you suddenly got a craving for hot dogs and go check the refrigerator if you have any ketchup. By the time you get there you have thought up something else incredibly brilliant and slowly starts to wonder what you're doing in the kitchen. You go back to the living room again and see the ketchup bottle on the table and remember "Yeah hot dogs! Awesome" and have forgotten everything about the idea you came up with going into the kitchen. What was that again,i never wrote that down,now it's lost forever,what if it was the cure for cancer ?
So back on topic again,however pleasant,mania is real disease and isn't good for you. It's the result of to much serotonin (or at least i think so due to empirical studies). So we already know we can adjust the level of serotonin with drugs from being Eeyore (the depressed donkey in Winnie the Pooh) to Tigger, who are you really ? Who's the "real" you ? How would you know ? What is "normal" and do we want it ? If you could choose to be a better you,would you ?
How does it manifest itself ? You don't know if you like apples all of a sudden ? That's just ridiculous. Or so i thought.
Turns out there's this thing called serotonin. It's a neurotransmitter that's thought to be responsible for feelings of happiness and well being. Great right ? Well if you have to little of it,you get depressed and life sucks and there's no point in doing anything. Yeah but that's a disease and there's pills for it. Yes there are, they're called selective serotonin reuptake inhibitors,Jesus Christ that's a hard sentence,why don't we just call them "happy pills". Yeah people refer to them as that or Prozac which is a popular brand of SSRIs.
They're absolutely great,turns out though they can be a bit too good. You can become manic from them. That sounds a bit scary however i guarantee you it is not! It's the best thing in the world! You're smarter and more creative than you've ever been in your whole life and who wouldn't want that ? It's the best high in the world,you don't want to get high/drunk (choose your poison) you're perfect as you are,why change that ?
You are as happy as a pig in shit and brilliant ideas doesn't seem to stop, appearing to you seemingly out of thin air.
Ok so there are some downsides. You get so excited you become a bit reckless. And it's really hard to focus because you have so many great ideas at once. Just as you're on the verge on solving unified field theory,you suddenly got a craving for hot dogs and go check the refrigerator if you have any ketchup. By the time you get there you have thought up something else incredibly brilliant and slowly starts to wonder what you're doing in the kitchen. You go back to the living room again and see the ketchup bottle on the table and remember "Yeah hot dogs! Awesome" and have forgotten everything about the idea you came up with going into the kitchen. What was that again,i never wrote that down,now it's lost forever,what if it was the cure for cancer ?
So back on topic again,however pleasant,mania is real disease and isn't good for you. It's the result of to much serotonin (or at least i think so due to empirical studies). So we already know we can adjust the level of serotonin with drugs from being Eeyore (the depressed donkey in Winnie the Pooh) to Tigger, who are you really ? Who's the "real" you ? How would you know ? What is "normal" and do we want it ? If you could choose to be a better you,would you ?
Say hello to Hedy Lamarr.
Is she the most attractive woman in history or what ? I died a little when i first saw that picture.
Now some of you might say that's awfully shallow of me,right ? Judging her purely on her looks, she's a person not an object.
How someone looks is the first thing you notice when you meet someone. It's far from everything but it does count for something.
And if all i had to say was "Wow look, hot chick, huh huh....huh huh" i'd agree with you but if you knew me you'd know there's more. Plenty more.
She was born in Austria in 1913. She was of Jewish descent. She gained fame after starring in Gustav Machatý's Ecstasy, a film which featured closeups of her character during orgasm in one scene, as well as full frontal nude shots of her in another scene, both very unusual for the socially conservative period in which the bulk of her career took place. In 1933, 19 years old, she married what was reputedly the 3rd wealthiest man in Austria Friedrich Mandl. A munitions manufacturer, also jewish (well half jewish actually).
Now by now some of you might feel a bit uneasy with me mentioning they're both jewish. What's that got to do with anything ?
It turns out in the 30ies ammunition was a really hot commodity and her husband being a munitions manufacturer and all had close bonds,both business and socially, to the goverments in both Austria and Germany.
In fact he hosted lavish parties that both Benito Mussolini and Adolf Hitler attended! Hence them being jewish raised my eyebrows a little. She also met several scientist and general people involved in military science which sparked her interest.
Her wealthy husband didn't feel much like sharing his young attractive (she was 17 years his junior) with the world so he became really protective of her,holding her a virtual prisoner in his castle. Hedy couldn't have that of course so she hatched a plan on how to escape. Luckily for her a new maid had just started to work for them who looked awfully similar to Hedy. Hedy asked her husband if she could wear her best jewels for dinner (needs money for the escape. A woman of her social standing obviously couldn't go empty handed.) she drugs the maid,changes into the maids clothes and makes her escape. Her loving husband soon becomes suspicious and starts to chase after her. Now the story is,to avoid being detected,she hides in a brothel with her husband hot on her heels. She hides in an empty room and in comes an unsuspecting customer,to avoid being detected she does what she has to do and sleeps with the man. Now she denies this part of the story but still it's a good story and a good story trumps a boring truth. So yeah it totally happened.
So off to England, then on to Hollywood,changing her last name from Kiesler to Lamarr in homage to one of the big stars of the silent film era, Barbara La Marr. You know the usual stuff, like you do.
So became a huge movie star, doing 18 films between 1940 and 49. And having two kids. So yeah she was a busy girl alright. That's quite a track record for working mother in any age not to mention in the 40ies.
Oh and did i mention in 1941 she co-invented Frequency-hopping spread spectrum, the basis of all modern wireless communication and getting a patent for it in 42 ?
Wait,she did what with the what in the what now ?
Yup that wireless internet on your laptop and the cellphone in your pocket,she made the invention that made all that possible. Basically life as we know it today. Her neighbour was avant garde composer and she came up with the idea while he was experimenting with some self playing piano or something. What if we transmitted radio signals to torpedoes using different frequencies,like the notes on a piano,wouldn't they be much harder to jam ? Turns out they are, instant legend. Or, not so, unfortunately.
Remember this was the 40ies and woman was generally viewed upon as someone to cook and raise your children and in the best of worlds being really easy on the eyes and that's pretty much. So the conversation went something like this:
"Hi General, this being WWII and all and blowing shit up is the order of the day,wouldn't it be great if our stuff did and their stuff didn't ? I can fix that"
"Well you know you really shouldn't bother your pretty little head with these matters,leave that to us men. But hey,you sure are pretty,how about performing for the troops,boosting their morale ? You know, show a little leg,a little cleavage ? Every effort is worthy for the cause"
"Well jeez thanks a bunch"
"You're welcome honey."
Fast forward to 1962 and the Cuban missile crisis and the business of blowing shit up and preventing the bad guys from doing the same became real urgent. What if there was a way of doing that ? The Navy quickly put their best minds on the task and much to their surprise someone already had,20 years ago. And by now we all know who that was. She later got recognition for her work,tons of money yada yada yada but that's another story.
So yeah, Hedy Lamarr, voted 7th most beautiful woman in history, partying with Hitler despite being Jewish, raising two kids during and extremely busy and successful career and taking time off to invent the world as we know it. My kinda gal. Beautiful women can be smart and smart women can be beautiful. That's not just some lame inspiration speak,it's way deeper than that,think about it. Really think about it.
And finally, monsieur, a wafer-thin mint.
Ok now for something lighter. The last ones got pretty heavy.
Gåte.
That means riddle for those of you not familiar with Norwegian (which i am btw).
They're like the greatest band ever. Heavy influence from Norvegian folkmusic obviously but plenty of modern stuff as well. Some remind me of Depeche Mode (another favourite) and others of Massive Attack.
In fact there's a bit of everything in the mix there. They made 2 albums and there isn't a single weak track on them but now they're split up unfortunately.
And then of course there's Gunnhild. Wow. Just wow.
She's like a force of nature or something from Norse mythology. I imagine her being a mythical creature in a time where Norway was completely flat,breaking the shoreline with her extremely powerful voice,thus creating the mountains and fjords and being locked away forever due to her destructive powers.
Or luring,seducing sailors onto reefs in the mists so prevalent on the Norwegian costs. Or something.
Now she's all grown up and perfect and stuff but funnily enough she was a real outsider as a youngster. The weird little sister to the drummer in Gåte, Martin. She was the geeky girl who practiced kulning or herding calls. Cow yelling basically. If you've never heard of it,it is extremely loud. It's absolutely piercing, necessary for the cows to hear you over great distances. And once you overcome the sheer volume of it, strangely alluring. That's where that amazing voice comes from.
It is also a lesson to not overlook the weird chick in the corner. She might turn out to grow up to the closes thing to goddess you'll ever meet. And you didn't talk to her while you had the chance. Boy,do you feel stupid now ? Don't we all ?
Gåte.
That means riddle for those of you not familiar with Norwegian (which i am btw).
They're like the greatest band ever. Heavy influence from Norvegian folkmusic obviously but plenty of modern stuff as well. Some remind me of Depeche Mode (another favourite) and others of Massive Attack.
In fact there's a bit of everything in the mix there. They made 2 albums and there isn't a single weak track on them but now they're split up unfortunately.
And then of course there's Gunnhild. Wow. Just wow.
She's like a force of nature or something from Norse mythology. I imagine her being a mythical creature in a time where Norway was completely flat,breaking the shoreline with her extremely powerful voice,thus creating the mountains and fjords and being locked away forever due to her destructive powers.
Or luring,seducing sailors onto reefs in the mists so prevalent on the Norwegian costs. Or something.
Now she's all grown up and perfect and stuff but funnily enough she was a real outsider as a youngster. The weird little sister to the drummer in Gåte, Martin. She was the geeky girl who practiced kulning or herding calls. Cow yelling basically. If you've never heard of it,it is extremely loud. It's absolutely piercing, necessary for the cows to hear you over great distances. And once you overcome the sheer volume of it, strangely alluring. That's where that amazing voice comes from.
It is also a lesson to not overlook the weird chick in the corner. She might turn out to grow up to the closes thing to goddess you'll ever meet. And you didn't talk to her while you had the chance. Boy,do you feel stupid now ? Don't we all ?
Acid cures suicide headaches.
Ok this is not going to be pleasant.
There's this affliction called Cluster Headaches. Some doctors and scientists have described the pain resulting from cluster headaches as the most intense pain a human can endure. The pain is so intense it has been given the fairly unflattering nickname "Suicide Headaches". Doesn't take a genius to figure out why.
It's so debilitating some sufferers actually tear their own hair own to get some sort of relief. I could go on but let's just agree it's pretty bad,okay ? This stuff is hard enough to stomach as it is.
Now here's the good news ! There's help ! It turns out a small dose of the good ole' LSD actually helps a lot of people. Yes LSD the hallucinogenic drug known as Acid (due to it being....well... an acid). Well is that great or what ? Well there's the small problem LSD is,believe it or not, illegal,yeah there's that of course.
So we aren't 100% sure if it helps.if it helps some or none because doing research is really hard and pretty much banned.
Well some argue,drugs aren't exactly helpful for your health either and they do have a point. Kind of. Well not really. LSD is actually surprisingly benign to the human body. The mind is another matter,the jury is still out on that one,let's just say that. LSD isn't poisonous. You can't really OD on LSD,at least there's not one case of LSD overdose that led to death from biological reasons. Compare that to common pain relievers sold over the counter. And surprisingly enough it isn't addictive either. Apparently there's some sort of mechanism where you need to get off it for a while for it to have any effect. If you keep on using it won't work. That's pretty neat.
It seems as though LSD shortens the attacks,they get less painful and further time passes between them. However we're not completely sure if that's the case or not and we can't study it because it's illegal. Imagine having the worst pain in the world,knowing there's a cure for it and you can't have it. Wow i didn't think i would want Cluster Headaches any less but it turns out it was possible. That must be the height of irony ? Well you would think so, wouldn't you ? But wait,there's more.
What i've been talking about is known to chemists as LSD-25. There's a similar molecule called 2-bromo-LSD. Pretty much the same thing except it isn't hallucinogenic.
"Well where's the point in that ? If i don't get goofy,why take it?".
Well it turns out, some research suggest it has the same effect on Cluster Headaches as it's wacky cousin!
Now that's just swell,isn't it ? Yeah absolutely if it wasn't for the fact that,as i understand it,it's illegal too!
"But didn't you just say LSD is harmless to the body and if this stuff doesn't get you all aligned with universe and stuff,what's the problem?".
Well i don't know. From the looks of i'd say they're deliberately letting people suffer from the worst pain known to man simply not to be associated with "drug liberals". If that's not the most cowardly thing i've heard in like forever i don't know what is.
"That's a pesky situation" says Bill.
"The situation is pesky" says Bull.
And i almost forgot,apparently it can be really helpful against alcoholism too. This horrible disease or whatever you choose to call it that affects so many life's everyday,yeah that alcoholism. Maybe would could save an almost unprecedented amount of suffering in the world but choose not to. That's sweet, ain't it ?
There's this affliction called Cluster Headaches. Some doctors and scientists have described the pain resulting from cluster headaches as the most intense pain a human can endure. The pain is so intense it has been given the fairly unflattering nickname "Suicide Headaches". Doesn't take a genius to figure out why.
It's so debilitating some sufferers actually tear their own hair own to get some sort of relief. I could go on but let's just agree it's pretty bad,okay ? This stuff is hard enough to stomach as it is.
Now here's the good news ! There's help ! It turns out a small dose of the good ole' LSD actually helps a lot of people. Yes LSD the hallucinogenic drug known as Acid (due to it being....well... an acid). Well is that great or what ? Well there's the small problem LSD is,believe it or not, illegal,yeah there's that of course.
So we aren't 100% sure if it helps.if it helps some or none because doing research is really hard and pretty much banned.
Well some argue,drugs aren't exactly helpful for your health either and they do have a point. Kind of. Well not really. LSD is actually surprisingly benign to the human body. The mind is another matter,the jury is still out on that one,let's just say that. LSD isn't poisonous. You can't really OD on LSD,at least there's not one case of LSD overdose that led to death from biological reasons. Compare that to common pain relievers sold over the counter. And surprisingly enough it isn't addictive either. Apparently there's some sort of mechanism where you need to get off it for a while for it to have any effect. If you keep on using it won't work. That's pretty neat.
It seems as though LSD shortens the attacks,they get less painful and further time passes between them. However we're not completely sure if that's the case or not and we can't study it because it's illegal. Imagine having the worst pain in the world,knowing there's a cure for it and you can't have it. Wow i didn't think i would want Cluster Headaches any less but it turns out it was possible. That must be the height of irony ? Well you would think so, wouldn't you ? But wait,there's more.
What i've been talking about is known to chemists as LSD-25. There's a similar molecule called 2-bromo-LSD. Pretty much the same thing except it isn't hallucinogenic.
"Well where's the point in that ? If i don't get goofy,why take it?".
Well it turns out, some research suggest it has the same effect on Cluster Headaches as it's wacky cousin!
Now that's just swell,isn't it ? Yeah absolutely if it wasn't for the fact that,as i understand it,it's illegal too!
"But didn't you just say LSD is harmless to the body and if this stuff doesn't get you all aligned with universe and stuff,what's the problem?".
Well i don't know. From the looks of i'd say they're deliberately letting people suffer from the worst pain known to man simply not to be associated with "drug liberals". If that's not the most cowardly thing i've heard in like forever i don't know what is.
"That's a pesky situation" says Bill.
"The situation is pesky" says Bull.
And i almost forgot,apparently it can be really helpful against alcoholism too. This horrible disease or whatever you choose to call it that affects so many life's everyday,yeah that alcoholism. Maybe would could save an almost unprecedented amount of suffering in the world but choose not to. That's sweet, ain't it ?
Prenumerera på:
Inlägg (Atom)