Main | November 2006 »

July 11, 2006

64-bit xine-lib fix

amaroK built for x86_64 was randomly crashing on me when playing AAC files through xine-lib. I tracked down the problem to an implicit pointer conversion in xine-lib (moral: always declare your functions), but someone had already found it:

xine-lib built from CVS should work. bug

I've tried this on a number of Movable Type 3.2 blogs out there, and it doesn't happen on theirs, but when you pass a badly formed query string to a CGI script, such as the query string in the Select a Design using StyleCatcher link at the bottom of the Templates page, extlib/ croaks with the error:

Use of uninitialized value in hash element at /mt/extlib/ line 554

That's if you're lucky and you're debugging with cgiwrapd. Otherwise you will probably just get an HTTP 500 Internal Server Error.

The offending link looks like this:


But I was also able to make mt.cgi die by just passing it


Here's a patch which fixes the problem for me.

--- MT-3.2-en_US/extlib/  Wed Oct 12 08:55:56 2005
+++ mt/extlib/    Tue Jul 11 19:18:56 2006
@@ -546,6 +546,7 @@
     foreach (@pairs) {
        ($param,$value) = split('=',$_,2);
+       next if not defined $param;
        next if $NO_UNDEF_PARAMS and not defined $value;
        $value = '' unless defined $value;
        $param = unescape($param);


The Movable Type MTEntryExcerpt tag is annoying in that it adds an ellipsis (...) even if the entry body is short enough that it doesn't need to be truncated. Here's a patch that fixes this behavior.
--- MT-3.2-en_US/lib/MT/Template/     Tue Oct  4 17:01:01 2005
+++ mt/lib/MT/Template/       Sun Feb 12 00:14:12 2006
@@ -1045,7 +1045,11 @@
     $words = 40 unless defined $words && $words ne '';
     my $excerpt = _hdlr_entry_body($ctx, { words => $words, %$args });
     return '' unless $excerpt;
-    $excerpt . '...';
+    my $body = _hdlr_entry_body($ctx, { words => ($words + 1), %$args});
+    if ($excerpt ne $body) {
+       $excerpt .= '...';
+    }
+    $excerpt;
 sub _hdlr_entry_keywords {
     my $e = $_[0]->stash('entry')

pair Networks

Maitreya and I host several domains and Movable Type blogs with a single Advanced Account at pair Networks. pair is a little more expensive than their competitors, like DreamHost, but I like them because they're based in Pittsburgh, don't oversubscribe, never have downtime, and provide easy-to-use configuration tools. They've also never implemented stupid policies like counting your CPU minutes. They've been in business a long time and understand the business of shared hosting.

Here's a trick I use to host several different websites on without having to pay for additional virtual domains each month. I had to pay one-time vanity domain charges for each site, but I use the magic of mod_rewrite in an .htaccess file to provide the illusion that each site is hosted separately.

RewriteEngine on

RewriteCond %{SERVER_NAME} .*craftlog\.org$
RewriteRule ^index.html$ craftlog/ [L]

RewriteCond %{SERVER_NAME} .*princetonjudo\.(org|net)$
RewriteRule ^index.html$ princetonjudo/ [L]

RewriteCond %{SERVER_NAME} .*oomny\.net$
RewriteCond %{REQUEST_URI} !^/oomny/.*$
RewriteRule ^(.*)$ oomny/$1 [L] and are both Movable Type blogs stored in subdirectories of the document root. Requests for the front pages of each site are rewritten to requests for their subdirectories. is Ariel's website hand-coded in WordPad. Requests to Ariel's site are silently prepended with oomny/. I gave her full FTP access to the oomny/ subdirectory and just told her to code as if it were the document root of her server.

July 05, 2006

iTunes XML to M3U Converter

I couldn't get any of the various scripts floating out there to work.

Specifically, I couldn't get any of them to convert my music collection to M3U for import into amaroK. Either the script didn't work, ran only on a Mac, didn't convert 8-bit filenames correctly, couldn't handle UTF-8 encoded track names, or all of the above. So I wrote my own Python script to do it.

My music resides on an NTFS partition that is obviously not mounted as C:/My Documents/My Music/iTunes/iTunes Music on my Linux partition. The script takes an option for automatically replacing the path to the Music Folder with an alternate path, e.g., /mnt/Music/ or something similar. It takes an iTunes XML file as input and writes the playlists to .m3u files.