Cause and effect?
I’ve been doing some reading lately and a topic that has come up more than once is that of false causalities. It seems to be human nature to construct causalities that fit our worldview when in fact the only thing that can be objectively demonstrated is co-variation. We can see this when it comes to non-heterosexuality and the relative occurrence of mental health problems. Some people seems to have their interpretation of the fact that some surveys find depression to be more common among non-heterosexuals than in the general population as a direct cause and effect relation. You’re depressed because being gay makes you so! Well, I’m not sure about that, in fact I’m sort of convinced that is not the case. But how do you illustrate that interpreting co-variance as cause and effect is often problematic? With colorful diagrams of course!
Alexander sent me a link to this wonderful piece of graphics, from climate sceptic:
In the comments I found the only relevant question to ask: should we struggle to produce more oil, so the quality of the music will increase, or should we attempt to draft better composers and musicians into rock ‘n’ roll, so we can have more oil? I’m so confused! At least it made me smile.
Filed under Uncategorized | Comments (2)Falling through the sky
The reason that I haven’t written here in a while is that I have been busy having my 30th birthday, with associated celebrations. It has been great fun. Thanks to my amazingly thoughtful fiance Alexander I got a gift certificate for a tandem skydive that I had the great pleasure to redeem today. What a rush! Thanks to a whole bunch of friends I got a photograph joining me in the jump as well. Skydiving makes even a geek like me feel like a rock star. Amazing. I got a whole album of pictures.
Choir weekend
Hi there. I’ve spent this weekend with my choir, singing for many hours. It was hard work, but also lots of fun. The main part of our rehearsal work was focused on a suite of choral pieces written specifically for us by Jazz composer and saxophonist Joakim Milder to be preformed at the 40th anniversary of Umeå Jazz Festival this October.
The music is a quite spectacular mix of modern Jazz harmonics and contemporary classical music. The rhythm and pace is quite fluid, with lots of varying meters and the harmonics doesn’t stay in specific keys, but at the same time many of the passages are breathtakingly beautiful. One other common denominator of the music, from a more technical point of view is that is is really difficult to sing. The melodies doesn’t follow many of the common presuppositions that we have on melodies as well as rhythms. It is really bends the mind, and right now it feels a bit overwhelming to try to learn to sing it correctly. I have good hopes, however, that this will be spectacular when preformed.
Filed under Sångkraft | Comment (0)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)Vacation
I’m sitting on the balcony, with a quick summer thunderstorm pouring it’s rain down cooling everything down. I love the rain, lightning and thunder and a few days into my vacation I’m slowly getting into the pace where I can really enjoy it. 
Yesterday I was at a friend’s place and watched movies. We saw In Bruges and Cinema Paradiso. I really liked the first one, with Colin Farrell for once being cast in a role that seems to suit him. One of the things that impressed me the most was the the pacing of the first part of the film. It wasn’t slow or boring to watch, and at the same time it conveyed the strange slowness and contrast of two brutal hitmen being forced to walk around in medieval Bruges and succeeding more or less well in appreciating the architecture and culture. Step by step, hardly noticeable at first, the tempo increased and I got a strong sense of anticipation of the resolution that I rarely feel these days when watching film. The Shakespearean ending matched the rest quite well. All in all an excellent film.
Cinema Paradiso on the other hand, was not what I had hoped for. Appearing at position 93 on the IMDb Top 250 movies of all times my expectations was perhaps a bit too high. My tastes have a tendency to match the IMDB crowd most of the time, but obviously not here. I think the film was overly sentimental, slow and I had a difficult time connecting with the young protagonist in the beginning, even though he was positively charming and severely beaten and yelled at on several occasions.
What made the experience somewhat enjoyable, despite the identification problems, was the beautiful scenography and wardrobe, as well as the occasional glimpse into the political climate of Italy in the mid 20th century. Yes, I positively love the sweater that teen Salvatore wears in one scene. Too bad you got listen to far too many overly sentimental string arrangements. And that is from someone that loves Ennio Morricone and doesn’t have any problems with bombastic symphonic scores for lots of other films. Trying to end on a positive note, I am glad that I didn’t watch the Director’s Cut. 47 minutes longer.
Filed under Movies | Comment (0)
