Mercurial hook for

Update (9/2/10): Fixed bug when pushing multiple commits at once, silenced wget’s output.

Here is a Mercurial hook to send notifications to whenever it gets new changesets pushed to it. It requires python, wget, bash, mercurial, internet access and an uncommon sense of humour (the latter is only needed for bug reports).

To use, put something like this into your hgrc (either for a specific repo, or user or system-wide):

incoming.notifyio = /path/to/script

And then put this into a shell script, where you referenced /path/to/script before:


# User data (change this)


# Work out api url to send to.

emailhash=`echo -n $email | md5sum | cut -f 1 -d" "`

# Quotes urls.
alias quote='python -c "import urllib, sys; print urllib.quote_plus("'

# Get repo information
desc=`hg log -r $HG_NODE --template "{desc}"`
author=`hg log -r $HG_NODE --template "{author}" | sed 's/ <.*//'`
text="$desc ($author)"

name=`pwd | awk 'BEGIN{FS="/"}{print $NF}'`

title="Mercurial changeset added"
if [ -n $name ]; then
 title="$title in $name"

# text - The notification text. Only required field.
# title - The title or subject of the notification.
# icon - The URL for an icon to use for the notification.
# link - The URL for a link you want to associate with a notification.
# sticky - Set this to 'true' if you want the notification to be sticky.
# api_key - If you don't want to set it in the query string

text=`echo -n $text | quote`
title=`echo -n $title | quote`

#echo wget -O - --post-data $data $url
wget -q -O - --post-data $data $url

I take no responsibility for any loss of life, possessions or injuries sustained through the use of this hack. Please direct correspondence, thanks and hate mail to B.Posters, Devilish Lane, Cranbrook.

Published in: on February 7, 2010 at 1:06 pm  Comments Off on Mercurial hook for  

Semester 2 marks

Avast! Here be (dungeons and?) dragons! Actually, it’s just my marks for Semester 2 (which I’ve been rather slow in actually posting).

ELEC1601 – Foundations of Computer Systems: 90 (High Distinction)
INFO1905 – Data Structures (Advanced): 86 (High Distinction)
MATH1003 – Integral Calculus and Modelling: 71 (Credit)
MATH1004 – Discrete Maths: 80 (Distinction)
PHIL1012 – Introductory Logic: 92 (High Distinction)

A Merry Christmas to you all!

(on a side note, Presenter is coming along quite nicely, and has gained support for song lyrics and images – unfortunately, video support is still a little buggy…)

Published in: on December 22, 2009 at 9:17 am  Comments Off on Semester 2 marks  


Any resemblance to reality is purely coincidental.

(because you can never have enough Comic Sans)

Published in: on December 10, 2009 at 8:20 pm  Comments Off on Productivity  

Test post

Congratulations, you’ve won a prize!
Nope…nothing to see here, move along.

Published in: on November 11, 2009 at 1:31 pm  Comments Off on Test post  


I’ve been trying out deliverance, and it is a really nice way of theming websites.

My motivation to use it is this: I want a website, which has various apps (in my case, Trac, HGWeb, SVN, and more), and I want to give all the pages a common theme. Instead of learning each of those application’s theming languages (which would all be different, and some don’t even have theme support), I want something to work as a “filter” at the web-server level…which is what Deliverance does, basically.

Unfortunately, it has a few things which annoys me. For one, it implements it’s own web-server (deliverance-proxy uses paste.httpserver), and doesn’t let you choose how to deploy it (e.g.: mod_wsgi on apache would be nice for me). Also, only half of it has been written as WSGI middleware (well, let’s make that easily accessible WSGI middleware) – the bit which takes a theme and rules and transforms the content is available as deliverance.middleware.DeliveranceMiddleware. Unfortunately, link rewriting, response and request modifications aren’t included in that, so you have to use deliverance-proxy to get them. 😦

I’ve drawn two diagrams to illustrate my thoughts of how Deliverance should work, the first being how I currently understand it to be, and the second showing how I would like it to be. A disclaimer: representing Deliverance in a diagram was tricky, so it’s not 100% accurate. Please don’t take my lack of pedantry in drawing diagrams for a lack of understanding of how Deliverance works.

How deliverance works (according to me):
A diagram showing the scope of Deliverance - it notably includes deliverance-proxy, the front-end server.

How I think Deliverance should work:

A diagram showing my thoughts on the future of Deliverance - notably, it's entirely one bit of middleware, and just wraps another application (which could use URLMap and Proxy to simulate the previous behaviour)

Some notes on things I’d like to see changed:

  • Deliverance becomes completely usable as a WSGI application – any server can run all the components of Deliverance, instead of just deliverance-proxy.
  • Deliverance wraps another application, which then does any proxying. This way, XML configuration files are replaced with Paste Deploy ini files (using URLMap and Proxy for previous behaviour).
  • Allow different rules to use different themes (I’ve coded up some preliminary support – see #17 for more details).
Published in: on November 1, 2009 at 4:46 pm  Comments Off on Deliverance  

Links to stuff

The Daily WTF failing, my iRobot Simulation winning, my iRobot program failing.

In other news, NCSS Summer School applications are open!

Published in: on October 4, 2009 at 4:56 pm  Comments Off on Links to stuff  

Update time

Things I’ve done recently:

  • Participated in the ACM South-Pacific regional with Carlo & Ronny – we were the top 1st year team!
  • Wrote Huffman compression utility for INFO1905 assignment – Carlo & I worked out a really tiny way of storing the header. Now, it’s just back to writing unit tests and documenting… (incidentally, bits & bytes in Java != fun)
  • Got an account – getting real-time updates about stuff people are doing with Python is fun.
  • NCSS Challenge has officially finished – the Python streams finished a week ago, and the Embedded stream finished on Sunday, but there’s an extra challenge for the Embedded stream – and a nice prize to got with it!
  • Change the name of this blog – again. We can’t have it being consistent, can we?

Things to do:

  • Work on Presenter – this will probably be one of the things to do in my mid-semester break. The list of things to do has been slowly lengthening…
  • Complete everything on my TODO list… 😦

Something I discovered today: ZIP File Quine. I’m wondering if I can do the something clever like this with my INFO1905 assignment… 😛

Published in: on September 22, 2009 at 11:06 am  Comments Off on Update time  

Busy, busy, busy.

Uni assignments, NCSS Challenge, math quizzes (urgh!), Presenter, and also ACM training. Wow there’s heaps to do. I’m trying to uses Getting Things GNOME! to organise myself, and it works, but only when I use it. 😦 Clearly every organisation system should work even when I don’t use it. 😉

In other news, I got myself an account on bitbucket (yay for OpenID!), and published Presenter on it. Thanks to that, I noticed that I hadn’t updated the README before releasing 0.2. Whoops! I’ve also been thinking about the UI for adding / removing files from the runsheet, and I’ve got an idea which should be pretty, logical and intuitive – I just need to find the time to implement it! Also, a terminal handler will be coming as soon as I get some time… (which should be awesome for teaching Python with)

Also, PyPy is one of the more interesting things to compile, thanks to it’s fractal drawing. I should be bothered to write one of them these days, shouldn’t I?

The NCSS Challenge introduced an Embedded Stream, where the students get some modified Arduino boards to play with – lots of fun, especially the accelerometer. Unfortunately, the online marker is somewhat buggy and sensitive, so answering questions on the forum is usually not that much fun. 😦

Uni is going fairly well, except for my Integral Calculus course. I had a rather odd assignment for INFO1905, where they were assessing graph-searching (disguised as a degrees of separation problem which needed Breadth-First Search), when they haven’t even covered graphs in the lectures, let alone graph searching. I know we’re an advanced class, but seriously – that just means we’ll be able to learn faster, not know it already (even though I did…).

Finally, if you’re using IDLE on Windows, note that len(string.lowercase) != 26, unlike every other Python environment on the planet. Stupid, stupid, stupid. Fine, we’ll use string.ascii_lowercase instead.

Published in: on September 1, 2009 at 10:12 am  Comments Off on Busy, busy, busy.  

Google Reader

It’s been nice knowing you, but I’m giving you up.

No more reading RSS feeds during my computer labs, no more worrying about whether Google is spying on me by working out what kind of subscriptions I read.

Goodbye Google Reader, Hello undisclosed client-side RSS reader.

Published in: on August 18, 2009 at 10:37 am  Comments Off on Google Reader  

Presenter Prerelease

In the spirit of “release early, release often”, here is another release of Presenter.
This is an Alpha release, so it’s still got plenty of bugs (the obvious one is with Video playback).

I’ve provided a .deb package, so if you’re a Debian/Ubuntu user, it should be relatively easy to install.
If you don’t install any of the recommended packages (python-evince, python-gnome2-desktop, python-gst0.10), you’ll find it rather boring.

There are two main problems with the .deb package: it explicitly depends on python2.5, and the icon for the menu item doesn’t seem to appear unless you logout/login your session.
These are known problems, directly related to how I created the package – I’m working on fixing them before the beta release.

Also, if you can be stuffed, it is possible to get Presenter working on Windows, and video playback works – you’ll need PyGTK and PyGST (gstreamer bindings for Python).

You can get it from PyPI.
Deb package
Tar Gzip
Win32 Installer

Published in: on August 8, 2009 at 11:42 am  Comments (1)