I predict McCain
I’ve been following the US presidential election closely for more than half a year now, and when I got the message that Obama chooses Joe Biden as his vice president I changed my mind about who I think is going to win this election. My adjusted prediction is that John McCain is going to win.
I think that he can snatch a close victory in november because now Obama has basically invalidated his own best arguments. The Obama campaign likes to paint the picture of McCain as problematically old and part of the washington establishment, but now they have proven that being old and part of the establishment is not a problem when choosing a vice president candidate.
Also, I don’t think that you should underestimate Obama’s consistent opposition against the war in Iraq as giving him the edge that he needed to defeat Hillary in the primaries. Now that he has chosen a running mate that voted yes to the war, that argument is weakened as well.
Part of me thinks that this is kind of sad. I really liked the idea of an american president that was a brilliant public speaker. I also think that Obama is the smarter guy and being intelligent is one of the most important assets a president can have. On the other hand, with McCain we get a president that is pro free trade, which is a really good thing, especially for those of us living in Europe.
Filed under Uncategorized | Comment (0)Real soon now
After a long summer break, this week it is finally for the choir that I joined last year to resume the weekly rehearsals. I’m so happy to have a choir as a part of the regular rhythm of my life again. Singing together, and working together in a group to learn new music and to sound good together is a really interesting process.
I am fortunate to live in a city where there is a really good chamber choir, and I really enjoy the way we sound (well, almost always) as well as the challenges that we take on.
Filed under Sångkraft | Comment (0)A CRC-32 reversal implementation
(This post is mainly intended for fellow geeks. Non-programming readers of this blog may safely ignore this, I promise you won’t be missing out on anything useful.)
The CRC-32 checksum algorithm is everywhere. It is used to detect random data corruption in ethernet packets, PNG graphics files and—as it turns out—zip files. The basic idea is that a 4 byte checksum of a sequence of bytes of arbitrary length is calculated using a specific algorithm. The sender of a message constructs a checksum of the message and send it along with the actual data, and then the receiver can compare the checksum with it’s own checksum calculated from the payload data and use that information to detect random data corruption.
The algorithm is designed to be fast and easy to implement in hardware. You can view it as a machine that you feed bytes of data. At any time you can query the machine for a checksum value of all the data fed into the machine. Each byte fed alters it’s internal state so that a different 4 byte checksum value is returned. Even a single bit change in the incoming data will alter the checksum to a completely different value.
The algorithm is explained in a very detailed way with impressive clarity in A painless Guide to CRC error detection algorithms so if you are interested, please read that document.
My conundrum with regards to CRC-32 was that I would like to make a short-cut, calculating the resulting checksum of a short dynamic sequence of bytes (an ID3 tag) combined with a longer, static sequence of bytes (an MP3 file) without needing to re-calculate the checksum of the whole every time the dynamic part changed.
So, what to do. Calculating a backwards CRC-32 value for the latter part of the stream to be combined with the checksum of the dynamic part seems to be too hard a problem to solve. However, I got a tip from a friend that with a 4 byte sequence of “compensation data” the checksum can be reset to whatever value one chooses. That way the dynamic tag plus four well chosen bytes can be reset to a known good state for the CRC-32 machine to chug along from and arrive at a known destination.
I got a link to a paper describing an algorithm to calculate the magic compensation bytes, but I think that the description of the algorithm was so complicated that I decided to figure out a way to do it on my own. So, I did. After a bit of experimenting looking at the table based algorithm used in the GNU Classpath CRC32.java I found out a way to calculate the magic reversal bytes as a function of some current checksum as well as a desired checksum.
I have released the resulting CRC32Compensator.java under the MIT Free Software license, in the hope that someone else will find it useful or instructive.
Filed under Programming | Comment (0)Programming for fun and profit
I work as a programmer. Most days it is great, because I get to spend my days writing software and even get payed to do it. However, when writing commercial software unfortunately the most elegant solution to a particular problem is rarely the one that is reasonable to spend time on. Almost all the time, “good enough” is the goal.
As an example, a new functionality that we have just added to voxbiblia.com, the website i spend most of my days working on is the ability to create albums out of the audio Bibles available from our site. An album is a collection of Bible verses read by one of our voices. From a more technical perspective a collection is a group of MP3 audio files. We want those MP3 files to be easy to download and once downloaded we want them to have metadata that makes them show up in your MP3 player. Do achieve this we want to be able to generate metadata information on the fly and we also want to put a whole lot of MP3 files with metadata into a zipfile so that i can be available as one download. We have code to to all this (The ID3 metadata generator will be released as Free Software some day, I promise) and it works as expected but one aspect of the zipfile generation code is not elegant as I would want it to be.
The current solution needs to read each MP3 file into memory to be able to calculate it’s CRC-32 checksum before it can write it to the zip datastream served to the user. Since our server is quite powerful it is not a problem to read a few MP3 files into memory at the same time, but the thought that it must be a more elegant and efficient way of doing it was spinning around in my head. Since there is absolutely no justification for finding this solution, the one we had was good enough, I had to put this problem on the shelf for some time.
However, vacation came and when I thought about what to do that would be really fun and recreational I thought about this problem and I decided to try to solve it. So I did, and it was great fun. I will blog about the specifics of this little project in a short while, but for now I’m just so glad that I solved the problem.
Free advice to big media
I bet that one or two executives in the film industry is wondering what they can do to have people buy their product instead of just downloading the content from elsewhere. I have a humble suggestion: produce and sell something that is better or at least equal in quality to what can be downloaded almost for free.
One of the more absurd examples of this is the current high definition movie offering to people using Macs. I have a MacBook Pro which is fast and has a large screen and no trouble displaying HD content, as can be shown for example when watching movie trailers. Yet there is no way that I can get my hands on full length movies in HD format in any way blessed by the movie industry. There are no Blu-Ray players for Macs, and iTunes movie store has not yet opened here in Sweden. A quick visit to the bay however, shows quite a large supply of High definition movies, delivered without any limitations and easily playable on my mac with VLC.
In short, the choice consumers have is to play by the media companies’ rules, and get mediocre quality DVD movies or download via BitTorrent and get movies in the best quality that their computer can support. With a choice like that, it is no wonder the movie produces get in trouble.
Filed under Uncategorized | Comment (0)Different types of recreation
There are lots of different types of recreation that crops up when the tempo slows down in vacation times. I try to blog, write a bit of software, and my dear partner Alex has taken up crocheting. Yesterday I had a bit of trouble finding my laptop, buried in a pile of breathtakingly beautiful naturally dyed yarn. You could have worse problems.
ps. If you are interested in yarn, knitting and such stuff you should definitely check out my friend Linster’s blog Yarnlove
Filed under Uncategorized | Comments (2)