A Day With Catalyst

You may remember that after the Web Frameworks Evening I rashly proposed that I would develop a simple application with each of the frameworks mentioned. Earlier in the week, as good as my word, I took Catalyst out for a spin.

Out of the three frameworks Catalyst was the one I was most intrigued by. I’ve heard too many people in orange sunglasses rave about Rails for me to get really excited about it. Django is written in my favourite language so it’s going to have to be especially horrid for me not to like it. The idea of a web framework that pulls in all the best tools of the Perl universe peaked my interest sufficiently that Catalyst was the first framework I decided to try.

Now full diclosure time. I’m a bit of a Python bigot, but I thought, how many people learn ruby until they get wowed by Rails? If Catalyst is really good it could bring lots of new people into the Perl community. As a relative Perl newbie I make a good test of that idea. Would I find Catalyst sufficiently awesome that I would consider doing web development in something other than my native language?

perl -MCPAN -e 'install Bundle::Catalyst'

Three hours later after a series of cpan force installs I finally had Catalyst installed and not throwing empty Base Class errors. I know my way around CPAN I suspect the vast majority of people new to Perl don’t. You’ve just lost them.

OK onto the tutorial. It’s pretty good. Writing views is really nice. Dispatching URLs to different functions is dead easy. The debugging output of the test server is massively helpful. Right, onto templates. Hmmm…. OK you can call them explicitly by stashing the template name or it does a clever lookup on the name of the view or the function. Nice. I can see how you don’t need a lot of code to get real functionality out of this. It looks like a simple matter to knock up a function that passes an ID through and uses it for a database lookup. So I really need to move on in the tutorial and work out how to connect to my WordPress db and start grabbing some articles.

Well the tutorial only mentions SQLite while I, and probably 99.9% of the world, am runnnig MySQL. Bit of googling should sort it. OK, no your Base Class is empty? Oh. More google. Aha I can connect now. The test server shows me a class has been created on the fly for each of my tables. The table names match what is in the database so I’m confident it’s actually talking to the DB. Right one line of code is all it should take to get data out. I can pass in a valid ID on the URL and use that to grab a record just like they show in the tutorial. But all I get back out is the ID. More google.

Turns out you don’t get magic relationship mapping out of the box with MySQL and Catalyst::Model::CDBI. There probably is a way to do it but I can’t find any documentation on giving it a relationship map by hand. I’ve now spent nine hours trying to coax this whole thing into life so It’s time to cut my losses and move on.

In short if you are not already a Perl hacker who knows his way aroung Class::DBI or Class::DBIx you may not find Catalyst to your taste. Which is a shame because it has moments of greatnes.

Next time: Django

Web Frameworks Evening

Hearing about different web-frameworks turned out to be suprisingly fun. Even if there wasn’t enough room in the pub. It’s probably better for my Liver if I don’t drink.

Most examples you see of how to use Your Favourite Framework involve building some sort of applications from scratch. But it seems to me that it’s much more likely that you would inherit some pre-existing data source and have to build an app against it. So for the purposes of research I’m going to write a simple application in each of the frameworks discussed against a database that already exists; namely this here wordpress blog.

It’ll give me something to do at the weekend anyway.

It’s possible I’m loseing my sanity.

Dim Sum and Jasmine Tea

It being the friday of a particularly hectic week my colleagues and I decided to head on down to Ping-Pong for some Dim Sum. While not as good as the free for all that occurs at The New World, Ping-Pong has one awsome thing going for it: the Jasmine Tea.

It appears as a unprepossesing green lump in an empty glass. Once the boiling water is applied a miraculous transformation occurs.

it doesn't look like much


the transformation is complete

Debian ate my Webserver

I’ve been meaning to upgrade to apache2 for a while now. So I set about doing it yesterday as it was the only legacy app I had left on the debian testing box I run this blog from. The wordpress installation I use to run peapodpy.org migrated with minimal fuss. The mambo installation I was using for hlynes.com just died. No amount of prodding would convince it to come back.

I’ve been getting more irritated with mambo as time passes anyway so I decided to see if there was an easy way to migrate my blog to wordpress. Lo and behold mambo2wordpress does the job. Now all I have to do is figure out why the RSS feed is setting pubDate to 01 Jan 1970 for everything.

*Update*
Looks like it’s only the imported articles that have wrong pubDates. So hopefully as new entries go on RSS aggregators should be able to sort things out. Probably a formatting thing with the old articles that the RSS creator in WordPress is objecting to.

Making a Minimalist Bittorrent Client

I spent the weekend sorting out bittorrent support in Peapod so that it
wasn't quite such a mess. Previously I had hacked a version of
btdownloadheadless.py so that it would exit when the download
completed. I was then shelling out to this from within Peapod.
Obviously this is a less than ideal situation partly because it meant I had to escape URLs from the shell. So I hacked away at btdownloadheadless.py until I had a simple class I could call to do the bittorrent download. It gives almost no feedback
except a return code upon completion of the download.

from btclient import mytorrent
url = "http://www.evilgeniuschronicles.org/audio/egc-2005-10-10.mp3.torrent"
save_dir  = /tmp
torrent = mytorrent(url,save_dir)
ret = torrent.run()
sys.exit(ret)

If you wanted to carry on seeding rather than exiting on completion you could do:

torrent = mytorrent(url,save_dir,selfish=0)
torrent.run()

I then added a name == "__main__" section into btclient so that it can be used a simple bittorrent client.
btclient.py http://www.evilgeniuschronicles.org/audio/egc-2005-10-10.mp3.torrent /tmp
or to seed:
btclient.py http://www.evilgeniuschronicles.org/audio/egc-2005-10-10.mp3.torrent /tmp seed

btclient.py  can be downloaded from here or alternatively see our subversion repository where the latest version can always be found.

Hopefully someone will find this useful.

Playing Movies on the iAudio X5

I am enraptured by my new Cowan iAudio X5.
It plays both flac and ogg vorbis and appears to my linux box as a
standard USB storage device. Given this level of openness I’m willing
to forgive it for running some version of embedded windows.

However until today I hadn’t got around to trying to get it to play
back any useful videos. It comes loaded with some short video clips
which are basically adverts for other Cowan products. However by
interrogating these clips with mplayer I was able to glean the
following information.

VIDEO: [XVID] 160×108 24bpp 13.000 fps 189.4 kbps (23.1 kbyte/s)
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 48000 Hz, 2 ch, s16le, 128.0 kbit/8.33% (ratio: 16000->192000)

Now I’m no whizz with mencoder so I had to do some searching around until I found a good intro to using mencoder. With that in hand I was able to put together an encoder command that worked.

mencoder inputfile.avi -o outputfile.avi -ovc lavc -oac lavc -lavcopts acodec=mp3:abitrate=96 -ofps 13 -vf scale=160:108

I added the lower bitrate for the audio as some sources suggest that
this makes playback more stable. Theoretically the X5 will play back
video at 15fps but can get unhappy so sticking at 13 seems sensible.
Now I’m not sure that I’d want to watch Lord of the Rings at 160×108
but character driven drama like House or The West Wing is remarkably
watcheable at this resolution. I doubt I’ll use this feature day to day
but if I was preparing for a long flight I might whack a couple of
seasons of my favourite TV shows onto the X5 to serve as an alternative
to the inevitabley dreadful in-flight movie.

Continue reading Playing Movies on the iAudio X5

Adventure in RSS

Imagine my surprise when I discovered that the default RSS feed generator in Mambo doesn't support HTML. Madness!

Anyway having upgraded to RSSXT
I now have lovely RSS feeds. I'm trying hard not think about the
chocolate-teapotishness of an RSS feed from a CMS not doing HTML.

On the subject of RSS feeds here are some things that annoy me:

Not setting PubDate.
Adverts (seriously, just don't.)
Advertising Last-Modified or ETag in your HTTP headers but not sending
back 304 when they are used as part of the page request. Yes Liberated Syndication, I'm looking at you.

Continue reading Adventure in RSS