tisdag 28 maj 2013

No comment


The XOR swap algoritm.

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.

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.....

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 ?

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 ?



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 ?

I am Jesus!

tl;dr I'm Jesus! And God! Promise. Read the whole thing if you don't believe. It's really long.


Not only that i'm God too! Now that might strike as slightly pompous if not preposterous even but bear with me. If you knew me you would know i've been an atheist all my life and an outspoken one since age 10.
I always been suspicious of the stories in the bible. A burning bush c'mon, bushes doesn't just spontaneously burst into fire and even if they did surely there's a more plausible explanation than divine intervention no ?

So at age 10 (my mother loves to tell this story) i read a copy of the Children's Bible from cover to cover and when i was done i put it down and loudly declared: "Nah i don't buy it". And that's been my position ever since. "Because it says so" doesn't cut it. Not by a longshot.  Now, i don't think Jesus ever existed even as a historical person. Google "The Jesus Myth" for more info on that.

So still i persist that i'm not only Jesus but God too (apparently they're they same see The Holy Trinity and come back to me explain the logical holes in that one, but that is besides the point) , have i completely lost my marbles ? Well that's real possibility, mind you, but i have a rational explanation for all of it (as always i might humbly add).

It started with a discussion about cyber-bullying or net-hate as we like to call it here in Sweden. It wasn't much of a discussion to begin with as it was pretty much one-sided to begin with. Everyone told with varying amounts of affect how much they disliked it and how horrible they were and how unpleasant the whole deal was. Well me always in the mood for a good discussion and not one to shy away from a bit of the good ole' controversy obviously took the side of the cyber-bullies much to everyone's distaste.

"Who's he ? How dare he take the side of those despicable people ? How can he agree with something as unpleasant as that" and so on. I'm sure you can imagine. Well for one i don't avoid unpleasant topics. I try to understand. I understand the views of the pot-smokers,the net-haters,the satanists, the racists,nazis even, sex buyers and sellers even some child pornographers! Now wait a bloody minute,you're not saying you're defending child-pornography ? Well some of them. There's a well known case here in Sweden where someone got sentenced (i don't know to what actually,could have been prison, i don't know) for distributing Japanese Manga cartoons! Now unpleasant as the whole topic might be and Manga too for that matter they're cartoons for f**k's sake! We can't draw pictures anymore ? Who's the victim ? I don't like censorship. No strike that,i really really really don't like censorship in any way or form. As unpleasant as the consequences of that might be (and i don't think they will be,really) it's the choice between unpleasant and freedom and i sure know what i value higher.

Another thing that really scared me in the net hate debate was the top-down perspective. It was people in power who accused the voice-less and power-less in the name of democracy. Now i don't know about you but i find really scary. Is it just trying to regain a power that they ultimately is going to loose,as long as possible ? I don't know but the "has" trying to silence the "has-nots" really rubs me the wrong way. Maybe some of the more nasty ones are even caused by them not having a voice for so long. Am i blaming the victim here ? Or is it simply cause and effect ?

Now back to the potsmokers etc. I don't necessarily agree with them i but i make an effort to understand their point instead of just label them "unwanted elements" or unerwunschte as they're called in German.
Does their points of views go away just by banning them ? Or is it better to understand the root of the problem and attacking it that way ? If it needs attacking,that is ? Maybe as long as they don't bother anyone just accept them for what they are ? Or maybe try and reason with ? And if you do,don't you think it's good to know what they're coming from ? The level of success is ultimately decided on how well you know and understand them ?

Doesn't that make me a better man than others (if such a term even exists) ? "What you do unto the least of my children, you also do unto me? or something ? Doesn't that make me like.......errr......Jesus ? Or at least Jesus-like ? I kind of look like him too, with me rarely shaving and my long hair. I'll go with that.
"Yeah totally dude,you're like Jesus man"
Well thanks i try too.

So me being Jesus kinda makes sense but me being God is a "too tough pill to swallow", huh ?
Well not only me, everyone!
It started with the prayer:

"God grant me the serenity 
to accept the things I cannot change; 
courage to change the things I can;
and wisdom to know the difference."

which is so full of wisdom it almost hurts. It's like that Brad Pitt movie where Buddha or the Dalai Lama (who's real prick, by the way, contrary to popular belief) or whoever it was, said "If you have a problem and you can change it, it's not a problem. If you have a problem and you cannot change it,it's not a problem" 
"Wow that's like awesome dude;thanks".

However that whole God bit rubbed all the wrong ways as you can imagine. Then i started thinking the whole world doesn't really exist anyways (that's me being a nihilist again.I rule, end of story) we make it up in our own minds. I really want to go to New York,never been there. For all i know it might as well be made up like Atlantis or something. However it exists in my mind but if were to go there, it wouldn't really be like i imagine it. It would smell and there's stuff i haven't thought of and the temperature and the people and the garbage,the dirt, well pretty much everything. And there are no absolute truths. Everything is an interpretation of our minds filtered thru our experiences.
Now the Wicca's or modern witches or whatever they call themselves are on to the same theme. We are all our own God. Some Satanists believe the same. The aforementioned Aleister Crowley made some nods in that direction too i believe.

Now what's with the constant referencing of Satanists ? Well i try and understand the un-understandable (or is that standable ? idk), defend the undefendable (remember i'm Jesus) and it's interesting to take the opposite view,in fact it's one of my favourite pasttimes. And looking at pictures of them is a constant source of amusement) and fun is the ultimate law. There's always some common grounds with Libertarianism, believe it or not and some claim to be the real Christians which in it self is hilarious but the explanation makes some sense and is related to Libertarianism. More on that later. Or not. It depends.

Ok this is getting really long, i'll try and wrap it up now.
Well back to the prayer,who is it you're really praying to ? Who can do that for you ? Well the only being that really can is yourself. You and only you. Well that kinda makes you God,doesn't it ? And me for that matter? And it solves my issue with praying to God. Well if that's not WINNIG!! i don't know what is.

Phew that was almost a novel. I try and explain myself in a few words,guess i failed that miserably,huh ?


Well hope it was a good read.


I'll shut up now.


Promise.

lördag 25 maj 2013

Responsibility - Do you have it ?

So i thought about responsibility the other day from a philosophical perspective. There's a lot of talk about responsibility and how you must have it and i thought (as i mostly do): really ? Do you ?

I mostly think the other way from other people mostly out of spite and fun i guess but if we look at it seriously for a moment i do see both sides as opposed to most people which is good i guess.

So responsibility,do we have it ? I tried "tasting" it to see if i could find the answer.

We do have responsibility for our kids. Do we ? Really ? People do adopt them, we leave at school for several hours a day thereby leaving the responsibility to others,some people just don't give a damn about them while that is usually frowned upon clearly there's no absolute responsibility for your kids. Here you have it, here you don't.

"Ah but you have responsibility for yourself"!!!

Well do you ? Can you even say that ? What does it even mean ?
You are yourself, how can you separate the two ? Your life is yours only and what you do with it is your business and no one else's.

So you don't have responsibility for yourself in some absolute sense. That doesn't mean you can't take responsibility but you don't have one. Same with your kids, most would agree it's a "good thing" but it isn't absolutely necessary in a philosophical sense.

I then realized i'm a nihilist! Awesome,i always wanted to be one, even though i didn't really knew what one was. Turns out i was one all along or at least are now.

Now that does not mean i think people should start to be mean and start killing each other and stuff. That's not what i mean and even if that was a possibility almost all people wouldn't do it anyways.

Someone thought it was an incredibly bleak and pointless  outlook on life but i do not agree. You fill it with meaning,for you,not out of some universal rule what's right or wrong. To me that's more meaningful than "just because".

We had a discussion on morality and i thought pretty much "If it feels right, it is right" (now dammit i can't find who said it first, i thought it was Voltaire but apparently not. Aleister Crowely was on a similar trail in The book of the law. "Do what thou wilt shall be the whole of the law") and i was alone in that i tell's ya. People thought i was terrible basically but i think i saw the other side of the coin. You have your own responsibility to do the "right thing" not just sheepishly follow "just because". To me that's a much more moral moral than some absolute rule.

So you thought you had an eclectic taste in music ?

I just found out you could sort your most played tracks in Winamp and i found that the artists i listen to most is Robyn and Dimmu Borgir. I thought that was hilarious for some reason. I wonder how many other people have those 2 as their favourite artists ? Or am i completely alone ?




Well what can you say about that ? She's the coolest girl ever. She's as close to a real life Pippi Longstocking as you ever gonna get. Gotta love that.



Can't really decide if they're the coolest guys ever or the dorkiest. I did see a similar band in plain clothes and it simply didn't work. Music like this needs the drama,the costumes and the make up. Simple as that really.

Note to self: needs to buy new goat horn hat. The old one is getting a bit long in the tooth.


Colors/Colours

Bloody English speaking people,can't even decide on how to spell such a simple word.

Either way,i'm not a particularly aesthetic person (not saying i'm ugly,nor the opposite either for that matter) but it interests me deeply. I just can't do it myself,that's all. I do recognize beauty in objects when i see them and i know the techniques behind it,i just seem to lack the taste gene. My main interest is music and i have no problem knowing what i want and how to get there but vision is a completely different matter.

So what's the point in all this rambling ? Well i had an idea that brown and purple would make an excellent color combo and as you can see,it clearly isn't. It's fugly to be precise.

Now i imagine dark brown leather couch against a dark purple wall,that should look really good,yet when i choose those colors for thishere blog it looks horrible. Ah well,i tried,that's always something.

Or maybe it's because it's like... duh maybe you should try more than like 10 seconds. It isn't like the things you want becomes available to you you in an instant even though that is clearly how it should be (the theme for this here blog i might add,how things should be).

Completely random

I thought a post on random would be a suitable topic for a first post as my thought and interests may strike you as fairly random. However they aren't or at least i don't think so. I did think of writing some kind of blog statement but i hope it'll become obvious the more i write. You shouldn't talk about what you're going to do,you should talk about what you've done. Encourages action.



You've all seen this one,right ? If you haven't, go to xkcd.com and immerse yourself in his wonderful world of geekiness.

That's the funniest joke i've seen but as often (always?) with xkcd there's something deeper beneath the surface. What is random ? A sequence of 4:s is just as random as any other sequence. You could argue that random should be impossible to predict but unless you've seen the code you can't be absolute certain the next number is going to be a 4 even though all the previous ones has been. On the other hand a true random algorithm should be able to generate all possible permutations of valid numbers which clearly this one doesn't  (unless 4 is the only valid output but then there's no need for a random algorithm,is there?).

You often see random in situations where it isn't actually what you want. If you ask a 100 persons for a random number between 1-100 very few is going answer 1,50 or 100. 47 somehow feels more random than 50. Funny that, no ?


In acoustics there's a device called a diffuser which scatters sounds in "random" directions and in "random" phases. Does this mean you can just construct one any which way ? Of course not, there's a clearly defined maths behind it and the outcome is entirely predictable. It may look like you could just glue a bunch of random length wooden pieces together but that wouldn't work. It wouldn't work as expected.

If you imagine the diffuser being a reflective surface and then imagine a single ray of light hitting it,it would reflect back in a "random" angle and at a "random" time (due to the depths being different). If you move the ray slightly it would reflect back at a completely different angle and time,so is it random ?

Not really as it is completely predictable. On the other hand for it to be truly random it would have to move and we clearly don't want that.

So what is random ? Not as easy as one would imagine,huh ?