Books I’ve read lately
September 25, 2004
I’ve managed to get through a number of books lately. Here’s some of them:
I bought The Curious Incident of the Dog in the Night-time after seing it mentioned in someone’s blog (Joel Spolsky, perhaps?). It was funny and sad; enjoyable, but also frustrating. A thoroughly good read.
Not too long ago I read The Salmon of Doubt, a collection of writings by the late Douglas Adams. I must admit that I found this one rather boring; that is, up until the partially finished Dirk Gently novel. That part was quite good, but, alas, you guessed it, unfinished.
More recently than that I’ve read Terry Pratchett’s The Colour of Magic, The Light Fantastic and Equal Rites. Call me weird, but although I’ve heard more from others about the first two, I definately preferred the third. I can’t quite explain why, but it captured me in a way the two first ones did not. I simply found it much harder to put down.
I haven’t just read fiction either. Steven Levy’s Hackers is a fascinating tale of computer wizards spanning three decades.
I’ve also read a few tech books, but I’ll get back to them later.
Just my luck
September 21, 2004
Friday night I got a text message (sms) from a friend I haven’t seen in more than 3 years. He was at a hotell in London and wondered if I wanted to meet up for a beer. Unfortunately, I had gone to Norway the day before and would not be back until Sunday, at least. Which, incidentally, was the day he flew back to Norway. I hate life sometimes.
A fisherman puts down his oars
September 21, 2004
My granddad, Martin Longva, died late last Friday night.
Kvil i fred, bestefar.
Pictures online
September 4, 2004
I’ve put some pictures online. Among them are some photos from my trip to Norway earlier this summer. There are more pictures still to come though. I’ve not managed to develop them all yet…
Pragmatic investment plan online
September 4, 2004
A friend of mine recently published his pragmatic investment plan. His idea is that by publish something like new year resolutions (but more tech related) it will be easier to adhere to them. I think that’s a good idea and I’ve decided to do the same. Mine can be found here.
Phone improvement
September 3, 2004
The quality of my cellphone’s display has been a source of much annoyance since I bought it. Still, at the time of purchase it was the best I could get at a price I was willing to pay, so I’ve accepted it.
Bored out of my mind at work yesterday I took the phone apart with intent of cleaning the LCD, as it was quite dusty. I noticed the display had these two red flaps hanging off the end. “Hmmm,” thought I. “This looks curiously like those plastic protector covers you’re supposed to pull off.” So I did.
Now my phone has a much brighter and clearer display.
I shouldn’t have had to do that, should I?
Elegantly flipping back and forth between two states
September 3, 2004
You are programming, and you find yourself in need of flipping back and forth between two states. Toggling between 1 and 0 is easy; you just negate the current state each time:
state = !state;
Say you’re implementing a game, and you need to toggle between two users. You want to use the values 1 and 2 and leave 0 to be the empty space. You might do that like this:
if (state == 1)
state = 2;
else
state = 1;
This works, of course, but it’s a bit cumbersome. If you know (and your language supports) the ternary operator you might end up writing it like this instead:
state = state == 1 ? 2 : 1;
That’s a lot shorter, and seems to be exactly what the ternary operator was meant for. However, my favourite is a little trick I picked up (I think) while digging through the source of Gnome Iagno:
state = 3 - state;
This has the benefit of not using the ternary operator, which some people abhor and/or have trouble with. The only disadvantage is that it is a little less flexible with regards to the states you can flip back and forth between.