Frühjahrsputz

Achja, das Internet, der “rechtsfreie Raum”… Impressumspflicht, Datenschutzerklärung, Verlinken und Einbinden von Medien auf sozialen Netzwerken… ich habe ernsthaft keine Lust mich damit zu belasten. Das hier ist ein privates Blog, nur für mich (und Family), was unschwer an der Anzahl der öffentlichen Postings zu erkennen ist.

Ich habe pauschal alles entfernt um Abmahnern keine Grundlage zu geben. Die Webseite ist privat, ich verdiene damit kein Geld, ich habe kein Google Analytics eingebaut, es gibt keine Banner, die Seite dient ausschliesslich persönlichen und familiären Zwecken. Rechtsanwälte, Politiker: geht weg, verlasst diese Seite. Bitte.

You know it’s Christmas…

when the airline of your choice plays Christmas songs during boarding. And the girl in the row behind you hums along to “Do they know it’s Christmas”.

So cool.

Recently I needed to calculate the distance between two points. Not too difficult by itself, all you need is the square root of the X/Y distances:

sqrt( (x1 - x2) * (x1-x2) + (y1 - y2) * (y1 - y2) )

Thing is: CLDC 1.0 does not have a sqrt function, only CLDC 1.1 has… Plus, double and float are also both CLDC 1.1 – which is OK, since I only needed an integer value.

Wikipedia proved to be a good source of information, once more, so I found that I could implement the Newton Method to achieve the desired result. Since I had no luck finding appropriate code with Google that I could employ, I wrote the function myself. See code below.

Read the rest of this entry »

Memo to myself: code nuggets

This post is more for my own benefit than for the public out there. Whenever I do some coding (rarely, which is part of the problem) I come across a problem and, after some trying & researching, possibly a solution.

However, after some time this solution is lost in the depths of my source codes. And a new research is sometimes futile – plus I reject the notion of going through the hoops again, since I already should know what to do. So, now I’ll drop little code nuggets here, so I can find them again with less effort. It’s certainly not an entertaining post, but it helps me.

First item: toggling boolean variables

I like to work with boolean values, and sometime I need to toggle them. So a true becomes false and vice versa. Of course this should be a short oneliner. Not an if-else construct. A good approach is:

boolean = boolean ? false : true;

I tend to use the ?: operator ad nauseum… so  an even better approach is (and my preferred way to do it):

boolean ^= true;

What is this? A XOR assignment operator, similar to += or -= If boolean is true, then the XOR return false (because it is not an inclusive OR). If boolean is false, then the XOR returns true. Mission accomplished.

Out Of Office…

Well, you probably have received an automated out-of-office reply mail at some point in life. And maybe you have created one yourself already. Normally it’s just a sentence or two, saying "I’m not here, I’ll read your mail later." Here is one I received today:

"As you read this I might be sunbathing in the Andalusion sun, eating tapas or maybe reading a book. I will be back in the office on the 12th of September and will try to get back to you asap."

Just the though of the beach and tapas kind of relaxed me already, so this is definetely one of the more noteworthy messages.

Creative Commons License - © 2007 Codecat - powered by WordPress