New blog

I’ve decided to go old school on blogging and make a new blog run on static content and command-line tools. I don’t plan to update this site anymore, so if you have nothing better to do, follow me there.

I’ve updated the feedburner rss feed, so if you subscribed to that, you’re still good.


Need a new desktop

So my desktop is getting a tad clunky, even running Linux. I was thinking of replacing it, and just the tower, as I have all of the peripherals I need. I was thinking of dual-booting Windows and Linux maybe, to play the occasional commercial game, but nothing really heavy. Decent graphics card with good OpenGL support for Flightgear, and good Linux compatability.

For just the computer I wouldn’t plan on paying more than about $400.00 CDN, recommendations welcome. You’d think that PC prices would drop now that everyone and his brother seems to want a tablet, but it doesn’t seem to be happening, at least not that I notice.

Custom request headers in Python

Just to be fair, here’s the same example in Python, batteries included.


import httplib

conn = httplib.HTTPConnection('')
params = {}
headers = { 'X-Bender': 'Bite my shiny metal ass!' }

conn.request("GET", "/", params, headers)

response = conn.getresponse()


Not too painful.

Custom request headers in Mojo

I was just playing with the latest version of Mojolicious, while writing an HTTP client, so I’m using `Mojo::UserAgent`. Pretty cool, although I still think the documentation could be so much better.

I wanted to insert a custom request header and came across this, so I thought I’d share. Apparently it’s done via the event system, very nodejs-like.

use Mojo::UserAgent;

my $ua = Mojo::UserAgent->new;

$ua->once(start => sub {
    my ($ua, $tx) = @_;
    $tx->req->headers->header('X-Bender' => 'Bite my shiny metal ass!');
    print 'Request: ', $tx->req->url->clone->to_abs, "\n";

my $tx = $ua->get('');

print "Response body:", $tx->res->body, "\n";

In fact, it’s so nodejs-like that I’m thinking, who cares about nodejs? I already know Perl.

Post-transaction events in Django

So, at work I’m using Django quite a bit, and I ran into a problem where I need the database transaction to be committed, and then I need to trigger additional server-side code that will act on that data.

Putting all of this into the view function with a manually managed transaction sucks, far too much code. There’s transaction middleware, but by then your view function has returned. What to do?

Simple. I added my own middleware, and I return a new property that I tag into the HttpResponse object. Python is flexible enough to allow this hack.


So in my MslEventMiddleware, I look for a new property in the response, and if it’s present, I execute the requested command, which will happen after the TransactionMiddleware has called commit.

    def process_response(self, request, response):
        if hasattr(response, 'mslevent'):

Simple enough. Although a real post-processing API in Django would be helpful.

Eclipse is still mean to me

So in working on Android programming I’ve been working through O’Reilly’s book on the subject, or one of them at least, and I’m at the stage of including the jtwitter library to talk to twitter. So, I add it as a library in eclipse, and everything builds, and then when the app runs I get a spectacular backtrace with a NoClassDefFoundError exception on the very library that I just included, winterwell.jtwitter.Twitter. Umm, ok. Is it added or not?

Trying a variety of configuration changes, I’m unable to get it working, but I finally came across this post on stack overflow about moving the jar to the top of the classpath order. So under Build Path -> Order and Export, I move the jtwitter.jar to the top of the list.

Voila. It’s working now. Seems rather braindead to me, as should Java not simply search the entire classpath until it finds the the requested import? I don’t understand why this works, and that isn’t good, ’cause it’ll just happen again. If someone has an explanation I’d appreciate it.


Blogging in the mobile age

What a strange world where I am writing a blog post on my phone. Kinda slow going, even using this cool Swype app to speed things up. Mind you, I suck at it…

Perhaps a Bluetooth keyboard will be needed.

Anyone else phone-blogging?

Eclipse, you could be nicer to me

So I’m playing in Eclipse going through Android development HOWTOs. Yes, I know. Java. Thankfully there’s a scripting layer for Android, but I want to learn it all before I choose a toolset for a particular problem. Besides, Java ain’t all bad, just mostly.

Anywho, I fired up the HelloWorld tutorial, made my project, and very quickly found that Eclipse’s wonderful generated code that was going to save me all this work of typing Java didn’t compile. I got, “main cannot be resolved or is not a field”. Huh? The main it’s referring to is my main.xml file (can’t have too much XML eh Java?) describing the Android UI layout, under res/layouts/main.xml. Invoked through the ubiguitous Android R object. What do you mean it’s not there, you stupid machine??

So I do what any modern programmer does, after swearing at my screen repeatedly, I look up the error in google, and voila, I’m not alone. This post was particularly helpful. Apparently, it’s an Android SDK issue, which Eclipse invokes to create the project. Yo, Google! Get off your butts and fix it! Seems to me that you have time…

Bash, sometimes you suck

So, I’m trying to pass a ! character to a shell command. Should be simple right?

Not so much.

twit --post 'OMG...I'm out of stoppage!'
bash: !': event not found

Huh? Oh yeah, in the fine tradition of crappy shells like csh, bash uses ! to re-run commands from the command history. But you’d think that in a single-quoted string it wouldn’t interpret that, it would just pass it into the command I’m running. Nope.

Can I escape it with a backslash? You bet.

$ echo "foobar\!"

K, still not what I wanted.

Simple solution, don’t use bash.

sh twit --post 'OMG...I'm out of stoppage!'

Works fine in a POSIX mode.

Am I missing something? Is there a simpler way to get what I want? This blows the 80/20 rule totally.

Kanata Honda – The customer experience

I complain a lot about companies that provide poor customers service. It’s easy to do, as they’re so common, and it can be fun to read and shake your head at. I haven’t found a lot of material online about how good people can be, but it’s overflowing with complaints and rants. Human nature I guess, we bitch a lot more than we commend.

We bought a 2010 Honda Fit from Kanata Honda a while back, and you never know how a dealership is going to treat you once they have your money and they don’t have to suck up to you anymore. In general I never expect much, although I hope for the ideal. The car is too knew to have any major problems so far, although Honda is as cheapo as every other car company out there, and my OEM Dunlop tires won’t make it to 30000km at their current wear rate, which is ludicrous. Take your head out of your ass Honda, and put on decent tires.

But, the dealership is selling the cars, not making them. They rely on mark-up, and accessories like $200 steering wheel covers. Say no more. And, they rely on you coming in regularly for service, which I will not do if they are going to overcharge, or provide bad service. And they cannot afford to, as this is really their bread and butter. They don’t make much profit on the cars, the accessories are ridiculously overpriced, so that leaves service (Y’know, one of those reasons why Saturn killed their own electric car? Big I digress…).

So far it’s been oil changes, tire rotations, and I allowed a questionable brake service, and had them put in a block heater, which I love BTW. No service problems, good treatment, although their Wi-Fi was broken when I was there. Guys, c’mon. Me techie. Need Wi-Fi. Recently I had some questions, like where the jack points are for my floor jack instead of the provide scissor jack, and I dropped by yesterday to have a windshield wiper adjusted that was off due to ice buildup.

Each time the service guys at KH have just welcomed me in, answered my questions, and got me on my way without issue. I didn’t expect to be charged for the service and I wasn’t, and that’s the kind of service that keeps me coming in for oil changes. Sure, I’ll likely do my own in the summer, in the driveway, a few years down the road when most of the warranty is gone, but for now I’m drinking the Honda kool-aid and it doesn’t taste so bad. It’s our only car so I don’t have to cut corners on maintenance to try to pay for two, and I do question the services and usually allow them with some skepticism. If I was only keeping the car for 4 years I likely wouldn’t bother with anything but oil changes, but I like to keep my cars for 10 years, and I expect them to be built properly to last that long, if I give them a little love.

So, good job so far people. Keep it up please.