Friday, 22 August 2008

MyOnlineProfile.net launches

MyOnlineProfile.net has launched - as a Google AppEngine application.

MyOnlineProfile lets you catalog your public online profiles in one place - leaving you with just one link to give your friends and one link in your email signature.

I first wrote MyOnlineProfile as a Grails application - its a small application at the moment, so it didn't take long. However I did over-engineer it. I made the classic mistake of trying to solve the wrong problems and over-optimising. Luckily with being a small application and written with such a productive framework, I'm only talking about wasting hours rather than months.

I deployed it to my Linux VPS, but unfortunately, Java based applications take up quite a bit of resources just starting up and memory on a VPS costs money (recurring money). So there just wasn't room for it.

Hence re-writing it in Python for AppEngine. Being exposed to Python has been good for me - and relatively easy since Groovy opened my mind significantly and I was ready for the experience.

In addition to the language, the AppEngine environment is very much like Grails in that infrastructure is taken care of for you - just like database access is so transparent in Grails, it is in AppEngine.

These things make writing the application about the application rather than the technology or infrastructure - just the way I like it.

Monday, 11 August 2008

Converting from Flash to AVI

If you want to convert from Flash to AVI (on linux) there is a good script here. It uses mencoder to convert files specified on the command line to XVID or DIVX - files are created using the same filename, but with an avi extension.

Thursday, 7 August 2008

Prototype, JSON and Appengine

I am using prototype in a Google Appengine project, and while it worked on my development machine, after deploying it onto the Google infrastructure prototype wasn't parsing the JSON responses anymore.

In my code, I was returning the JSON in the response text (as opposed to using X-JSON response header). The Content-Type response header was set as application/json and my javascript code used Ajax.Request() with the parameter evalJSON:true so as to parse the response text.

Running locally with the dev_appserver.py everything worked okay. However when running the deployed app, the Content-Type header was no longer being set - meaning that prototype would never parse the response text.

I'm not sure why Content-Type doesn't get set when running on the Google infrastructure yet it works on the development server. But, luckily when using Ajax.Request, you can specify evalJSON:'force' so that prototype parses the response regardless of the content-type.

Server ajax response code:
result = func(args)
# content type doesn't work when deployed
self.response.headers.add_header("Content-Type", 'application/json')
self.response.out.write(simplejson.dumps(result))
Javascript Ajax request:
new Ajax.Request('/rpc',{parameters:{action:'add'}
,method:'post',evalJSON:'force',onSuccess:function(transport) {
var result=transport.responseJSON;
...
}
}
Response headers from Google:
Content-Type:    text/html; charset=utf-8
Cache-Control:    no-cache
Content-Encoding:    gzip
Date:    Wed, 06 Aug 2008 09:56:05 GMT
Server:    Google Frontend
Content-Length:    82

Saturday, 2 August 2008

Oracle types

It frequently surprises me when seemingly simple things are missing from mature products. For example, Oracle doesn't have a boolean type. Strange but apparently true.

Never mind, this article describes how to work around this.

Friday, 1 August 2008

Rename mythtv recordings

The files Mythtv records are saved with a timestamp as a file name, making it pretty hard to figure out which file is which.

To easily identify the files, you can use mythrename.pl - I couldn't find it in my Mythbuntu installation, so I had to download it from http://svn.mythtv.org/svn/trunk/mythtv/contrib/user_jobs/. It ran okay, without any dependency problems.

This post has some useful comments on how to run it. The idea is that you can schedule it with cron to run at regular intervals so as to stay current. I'm running it so it doesn't actually rename the original files, but it makes sensibly named symbolic links to the originals:

mythrename.pl --format "\%T/\%Y-\%m-\%d \%H\%i \%- \%T \%-\%S" --link /home/paul/TVShows

For help with the options, see the wiki page or run with the --help option.