I hate falling asleep

September 24th, 2006

There's a reason why sleep feels so good in the morning. There's a reason I like sleeping in, waking up, and staying in bed to get more sleep. It is such a wonderful change from trying to fall sleep and not succeeding. It doesn't happen to me a lot, once a month maybe. But when it does, it really pisses me off. Last night I felt tired, so I thought I'd try to go to bed early. I turned in at around 9pm and I sensed I was a little too alert to sleep. Nevertheless, I was determined to stick with it. After a while I hear noises from the kitchen, people talking and yelling. I knew this is not going to happen. Every time I try to sleep and can't is a defeat, which only adds that much irritation and bad experience to the night.

So I go to bed again at around 2am. By now the house is completely quiet. Just as I feel I'm falling asleep, a goddam fly buzzes right over my head and knocks me out of that feeling of losing consciousness. It is by being awoken from it that I actually know that I was about to fall asleep, cause by then I was already well on my way. And now comes the worst part, the thoughts. There's nothing worse in trying to fall asleep than starting to worry that it's not going to happen. I know this, but somehow the thought comes to me anyway. I try to push it away, but the moment I'm just a little bit conscious of it, I sense that I can't escape it. I try not to think about it, but it's there and while I'm not thinking about it, I'm conscious that it's just it's just one little thought away, so basically it's just as bad as consciously thinking about it.

I've heard people say that if you don't fall asleep within 10 minutes, then you're not tired enough to sleep right now. I cannot think of a time when I would take less than half an hour to fall asleep. So far as far as I'm concerned, that rule is nonsense.

One thing that really gets in the way of sleep is knowing that tomorrow there's something I have to get up for. This kills the prospect of a good night's sleep like nothing else. If it's just an everyday thing, it's not a problem. But if it's something out of the ordinary, a one time event, that is what triggers it. Again, I'm not obsessing about it, but I know that the thought is within reach. And at the first sign of insomnia, it comes knocking. Now there's pressure to fall asleep, cause there's a reason to be up at a certain time in the morning. A couple of times this has happened to me, I couldn't sleep for hours, I gave up and canceled my appointment, and then I could finally sleep.

So I try to distract myself from not sleeping. I watch some tv, a sitcom episode, surf the net for about 20 minutes, something to take my mind off not sleeping despite being increasingly tired. I go back to bed and the bed feels great. I lie on one side, after a while I turn to the other. The longer I'm not sleeping the more uncomfortable the bed feels. Suddenly it's hot, the pillow feels big, so I push it aside, I lie on my stomach, then on my side, on my back, again I can sense this is not going to happen.

I've tried various things to sleep, but I haven't found anything that really works. Taking a shower, going out for a walk, jogging to make myself physically tired, reading, watching tv, a glass of milk, a glass of water, coffee, tea, herbal tea, it's all just a stab in the dark.

Not falling asleep sucks. Eventually there comes a time when fatigue sets in (around 6am I'd say) to the point where falling asleep is very easy. Of course, by that time, any prospect of having a normal day tomorrow is long gone.

baby steps

September 22nd, 2006

6-0, 6-1. :D And an improvement of about 100% over last time, which doesn't show in the scoreline (did I mention I don't play well under pressure?).

The beauty about being rock bottom is that there's only one way to go. Up. :D

allofmp3.com is da bomb!!

September 22nd, 2006

In this day and age, with the consumer being treated like dirt, whenever a company launches an offer that is actually good, it's such a revelation. One such revelation (of which there are few), I discovered today, is allofmp3.com. I'm actually in awe of these Russian entrepreneurs. So let me tell you why that is.

  1. They let you preview a track before buying in low quality (this is actually disappointing, because you have no idea how it really sounds).
  2. They let YOU pick the encoding you want, among all the most widely used formats. How amazing is that? :cool:
  3. All content is usable (no DRM).
  4. The price of a track depends on the the sound quality you pick (ie. you pay by quality), but the prices are generally low.
  5. Their collection is wide enough to carry albums that I actually want.

To give you a concrete example.. The other day I was raving about "Chevaliers de Sangreal" from the Da Vinci Code movie. I search for the album on allofmp3, they have it. The price for this track (at 192kbps mp3) is $0.18. I put it in my basket, I set the encoding to FLAC lossless compression, the calculated charge is $0.71. Meanwhile, Apple's iTunes Store, as far as I know, charges $0.99 per track (I cannot verify this as the store is only available through iTunes, which of course, has no linux support).

Granted, their payment system is a bit of a pain. They make you transfer a minimum of $10 into your account before you can buy anything. And I had to do this through a different site, even had to use my cell phone to retrieve a pin code they sent me. But, if you're a frequent customer, just transfer $100 in one go and you won't have to do this for a long time again.

The one drawback I've seen is that while they keep track of the tracks you've bought (no pun intended), they won't let you re-download them. So once you download, keep it in a safe place (like backup to CD/DVD).

The average album on allofmp3 costs about $2.50, that is 11x, E-L-E-V-E-N T-I-M-E-S, less than the average album in a music store in Norway, at 180kr ~ $27 (perhaps Holland is a bit cheaper, I rarely go to music stores anymore, I wouldn't know). And for that you get tracks at 192kbps (which is fine for most music, soundtracks and classical is more demanding music, I might get that in higher bitrates or FLAC), and you can buy per track. Not to mention that I never use CDs, because mp3s are so much more practical (and even if I did I could burn the CDs myself). Give me one good reason why I should ever buy another CD again.

where do they get the flags?

September 20th, 2006

How many times have you turned on CNN only to see American flags being burnt on the streets somewhere? What always makes me wonder is.. where do they get these flags?? Are there flag stores on every corner in these cities? Is someone getting rich selling flags? Is there a flag millionaire mansion somewhere? Or are they home made? Would someone really labor over a flag for weeks, cutting the fabric, measuring, sewing (if you've ever sewn anything, you know how much work it is) only to set it on fire? Even making a big banner is less work than sewing a flag. All you need is some big chunk of paper and a magic marker. But a flag requires fabric in every color of the flag, it requires careful measurement, it requires a sewing machine (otherwise it *really* takes ages to assemble).

But either way it's such a huge waste. If you buy the flag and burn it, that's just like fireworks, a complete waste of money for a moment of fun. And if you produce it yourself, well that's even worse. Hours of labor wasted in a few seconds. The whole idea is lost on me.

cutting the fat off binaries

September 20th, 2006

What's amazing to me is that for every technical problem, there's already been lots of people who've thought about it and tried to solve it. Given the world population is at some 6 billion, that's not really surprising, nevertheless it's very satisfying. Like lately I've been having thoughts about writing a small application using the Qt library. I haven't even begun designing it, I've just been doing preliminary research. My concern is that the program should only be a single binary and it should be as small as possible. The reason for this aim is that I want to make it as accessible as possible - it should require only a small download, and no installation necessary. So if it's a single binary, that's the easiest way to accomplish this.

But, of course, using any library at all already adds filesize in the shape of dependencies. Since I only want a single binary, I'm looking to compile statically, which will include all the library code that I'm using. Qt in particular, is a huge library. It probably adds up to about 15mb of library objects, and I don't want all of that in my "little" binary.

Let's do this by example. A few years ago I was dealing with High Dynamic Range (HDR) images, I even wrote a tutorial on how to produce them starting with pictures taken with a digital camera. I used Greg Ward's hdrgen utility for this. Greg's program is a single static binary. Now, if Greg had the same goal as I do, there are a couple of things he could have done.

$ ls -lh hdrgen
-rwxr-xr-x 1 alex users 8.7M Oct 24 2003 hdrgen

So the file is over 8mb in size, is there any way we can shrink it?

$ file hdrgen
hdrgen: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.0.0, statically linked, for GNU/Linux 2.0.0, not stripped

The information we're looking for is shown here in emphasis. The file is not stripped, which means it contains a bunch of symbols that aren't strictly necessary for it to run. Symbols that ease debugging or relocating the binary. Also note that the binary is statically linked, which means it does not depend on any libraries to run.

The first thing we can do it strip the binary. Stripping removes symbols and leaves only the bare essentials.

$ strip -s hdrgen
$ file hdrgen
hdrgen: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.0.0, statically linked, for GNU/Linux 2.0.0, stripped
$ ls -lh hdrgen
-rwxr-xr-x 1 alex users 1.9M Sep 19 22:59 hdrgen

As expected, the binary is now stripped. Notice also that the filesize has been reduced from 8.7mb to just 1.9mb! That's pretty sweet.

But it doesn't end here. A further way to reduce filesize (for static binaries only!!), is to compress them. UPX is a way to compress binaries to reduce their size further. It is a lossless compression method (otherwise it would be useless, of course), which bundles the compressed binary, and everything needed to uncompress it, in a single file.

$ upx -9 hdrgen
Ultimate Packer for eXecutables
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
UPX 1.25 Markus F.X.J. Oberhumer & Laszlo Molnar Jun 29th 2004
File size Ratio Format Name
-------------------- ------ ----------- -----------
1889480 -> 694035 36.73% linux/386 hdrgen
Packed 1 file.
$ file hdrgen
hdrgen: ELF 32-bit LSB executable, Intel 80386, version 1, statically linked, corrupted section header size
$ ls -lh hdrgen
-rwxr-xr-x 1 alex users 678K Sep 19 22:59 hdrgen

The binary is now compressed. As you can see, the file utility is having some problems understanding what it is, because of the added compression. But the binary is definitely smaller, down to just 678kb!