Apr 302012
 

John Banks was given a very important job when government was formed after the November election, a position named Minister with Special Responsibility for Keeping His Month Shut for the Next 36 Months and Not Embarrassing the Government.

Would all of you who picked 26 weeks in the nationwide pool please raise your hands to claim your prizes. Judges will be around shortly to check your tickets.
Continue reading »

Dec 142011
 

When I was a child I used to amuse myself by imagining how things would look if light moved at a few meters per second. I thought it would be cool if you could walk into a dark room, turn on the light and watch as the light spread throughout the scene. Wielding a flashlight would be interesting – you could easily make curved beams.

Now these guys have built a camera fast enough to show the same effect:

Of course, they do cheat a bit by only taking a 1 dimensional slice at a time and relying on the fact that they can repeatably fire identical pulses of light to make their images. Still this is exactly what I imagined it would be like.

Now someone needs to build the high wattage laser targeting system capable of taking out houseflies without blinding humans that I invented when I was 9.

Apr 272011
 

While I don’t like Don Brash (or the Act party), I have to admire the concept of announcing your availability to be the leader of an organisation that you don’t currently belong to.

I would also like to take this opportunity to say that I am interested in being captain of the All Blacks during this year’s world cup. I will be holding talks with the All Black management tomorrow, but if unsuccessful I will form my own rugby team and lead it to glorious victory on the field. I have backers and financial support – so there!

May 252010
 

It was bound to happen. People seemed to enjoy the first TV Theme Quiz so I fired up Audacity and created another 30 seconds of familiar ditties. Things were solved pretty quickly last time so I tried to make this one just a smidgeon harder – we will see if I succeeded.

Start TV Theme Quiz II

This quiz works in much the same way as the last one but I have tweaked the Javascript a little. I never thought that anyone would bother reversing the hash used to hide the answers on the first quiz but one of my friends admitted that they had done just that. A little salt should clear that problem right up.

This is the post you should comment on for hints and bragging. I only ask that you refrain from posting the actual answers, at least for the first few days. I think it is better to let people work things out for themselves.

Nov 282009
 

I don’t usually do a lot of Python programming, but I always enjoy it when the opportunity arises. Python is in no way a “clean” language, it has all sorts of warts and limitations that mean that it tends to not get used for big projects. Despite this (or maybe because of it), Python remains my go-to language for Getting Small Things Done Quickly. It is impossible to overstate the utility of just being able to start coding a function by bashing away at the python console – nothing else has given me the same sense of instant gratification since I started programming in BASIC back in the 80s.

The other big advantage of Python is the useful utility libraries that come with it as standard. Want to send twenty thousand emails? Just import smtplib. Want to generate code based on data from a spreadsheet? Import csv and away you go. Need a file that is exactly 32Mb is size? No problem. These are real examples from my job where Python has saved me many hours.

The most recent use I have put Python to is a slow server. For various murky and uninteresting reasons I need a rate-limiting HTTP server, one that I can easily control the speed at which it sends data. Enter Python’s very handy BaseHTTPServer module, which allows you to create custom HTTP servers with only a few lines of code by subclassing a request handler. Although the BaseHTTPServer is fairly useless for serving real files, it is perfect for this type of thing since it does all the boring work of parsing headers and returning status codes.

I don’t care about the contents of the data, just its size and how long it takes to serve. Since I will be varying these parameters a lot, I decided to make them part of each request so that each request could take a different amount of time – this means I don’t have to restart the server between each test run. Modifying the code to serve actual file data would be very simple.

I enjoyed writing this server so much that I regret that it didn’t take longer. Now I actually have to use it for its intended purpose, which I can assure you is not going to be as pleasant.

Here is the complete Python source:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# A very simple HTTP server designed to for testing situations where the data returned
# is not important but the rate at which it comes down is. This server can be started
# using the command: python delayserver.py
#
# Once started, it will listen for requests on port 8000
# Requests should be of the form http://<address>:8000/size=<bytes>,duration=<seconds>
# where: <bytes> is the size of the response data
# and    <seconds> is how long you want it to take (at minimum, it may take longer)
#
# Notes:
# * The timing is pretty inaccurate for small byte sizes, this isn't a problem for
#   what I need it for
# * Press ctrl-c to stop serving
 
 
import time
import BaseHTTPServer
 
class MyHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
 
	def do_GET(self):
		request = self.path.strip("/")
		duration = 1
		size = 1024
 
        	validRequest = False
		params = request.split(",")
		for p in params:
                    temp = p.partition("=")
                    if (temp[0] == "size"):
                        size = int(temp[2])
                        validRequest = True
                    elif (temp[0] == "duration"):
                        duration = int(temp[2])
                        validRequest = True
 
                if (validRequest == False):
                   self.send_error(404)
                   return
 
                self.send_response( 200 )
                self.send_header( "Content-Length", str(size) )
                self.send_header( "Pragma", "no-cache" )
                self.end_headers()
                self.slowWrite( self.wfile, size, duration )
 
 
        def slowWrite(self, output, size, duration):
                bytesWritten = 0
                startTime = time.time()
                while ( bytesWritten < size ):
                        now = time.time()
                        if (duration != 0):
                                desiredBytes = ( (now - startTime) / duration ) * size
                        else:
                                desiredBytes = size
                        desiredBytes = min( size, desiredBytes )
                        if (desiredBytes < bytesWritten ):
                                time.sleep(0.2)
                        else:
                                while (bytesWritten < desiredBytes):
                                        output.write('A')
                                        bytesWritten = bytesWritten + 1
                                output.flush()
                now = time.time()
                self.log_message( "Request took %f seconds",   now - startTime  )	
 
if __name__ == "__main__":
    http = BaseHTTPServer.HTTPServer( ('', 8000), MyHTTPRequestHandler )
    print "Listening on 8000 - press ctrl-c to stop"
    http.serve_forever()

I should point out that I am by no means an expert at Python, so take this code with a pinch of salt.

Jun 282009
 

I load up Facebook and what do I see?

“Once you’ve been tagged… (1) Turn on your MP3 player. (2) Go to SHUFFLE songs mode. (3) Write down the first 25 songs that come up–song title and artist–NO editing/cheating, please. (4) Choose 25 people to be tagged. It is generally considered to be in good taste to tag the person who tagged you.

If I tagged you, it’s because I’m betting that your musical selection is entertaining, or at least amusing.

(To do this, go to “NOTES” under tabs on your profile page, paste these instructions in the body of the note, enter your 25 Shuffle Songs, Click ‘Preview’ below to tag 25 people (in the right hand corner of the app) then click Publish, the little blue box at the bottom of your screen).”

Damn! I’ve been tagged with the 25 Random Songs meme-virus. Oh well, here goes:

Beauty Has Her Way by Mummy Calls (The Lost Boys Soundtrack)
I listened to The Lost Boys soundtrack religiously when I first got it, and while I still like it a lot there is no denying that it contains far too many sax solos. The whole CD could easily be the soundtrack to Saxophone:The Movie.

Who Put the Bomp (In The Bomp Ba Bomp Ba Bomp) by Barry Mann
I grew up in a small town with only one radio station. Looking back they did a pretty good job of trying to satisfy everyone, but means that I know more about 50s and 60s music than I do about, say New York punk. Anyway, they used to play this song – basically a piss-take on DoWop bands. I still find it hilarious.

E=mcHawking
I explode like a bomb. No one is spared;
My power is my mass times the speed of light squared.

I don’t know where Stephen Hawking finds the time to be both the Lucasian Professor of Mathematics at Cambridge and a hardcore gangster rapper simultaneously.

Pulp Culture by Thomas Dolby
I got this from a Thomas Dolby Best Of, pretty good stuff, although this is not one of the standout songs.

Como Sera by Edgar Joel
I bought an album of salsa music a while ago. It is pretty cheesy.

Merry as a Grig by Van Philips (Ren and Stimpy Production Music)
Ren and Stimpy made a point of plundering recording archives for old-old-timey orchestral music. Lots of muted trumpets and xylophones.
I have just realised I have no idea what a Grig is, nor why one should be merry.

Jango’s Escape by John Williams (Star Wars Episode 2 Soundtrack)
The music was the best part about Star Wars, and this is one of the better pieces.

Christmas is Interesting by Jonathan Coulton
From a CD I ordered online after I downloaded a couple of songs off his website after he was linked to the Wikipedia page on The Mandelbrot Set, of all things.

A Thousand Miles by Vanessa Carlton

Grieg: Peer Gynt Suite #2, Op. 55 – 3. Peer Gynt’s Homecoming
I have a whole bunch of classic CDs in my library, mainly for when I am working and I need to concentrate. I was debating whether to exclude the classical stuff from this list, but it seemed like cheating.

Gummi Bears Theme
For a while I was collecting TV theme tunes. I cannot recall how I got started, but I still have them. This one always makes me smile when it comes up on shuffle – The Gummi Bears was a pretty good show.

The Sixth Sense Malcolm Is Dead – James Newton Howard (A History of Horror)
One fine day about 8 years ago I walked into Borders with too much money. I solved that problem by buying A History of Horror, a two CD set of horror movie themes going back to the 1920s. It has some great music on it, but also some tedious muck (this track lies somewhere in between.)
I recall that I was torn between buying this or BatBoy:The Musical original cast recording. I am still not sure if I made the right decision.

More Than A Feeling – Boston
Sometimes you just have to close your eyes and drift awaaaay… Ironically a song about reminiscing over an old song has turned into an old song that reminds me about my youth. God that makes me feel old, but I bet not as old as it makes the members of Boston feel.

Swear It’s True – The Mockers (25 Years of Kiwi Rock)
I liked The Mockers, but Forever Tuesday Morning is a better song.

Second Solution – The Living End
The Living End are still going, but rebellious punkesque bands really have a hard sell-by date (c.f. Green Day). This is them from their prime.

Crepe Suzette – Cyril Watters (Ren and Stimpy Production Music)
More Ren and Stimpy

Org Con in B flat, Op.4, No.2 – Halleluja
I once help win first place in a quiz by knowing that Handel’s Messuah was first performed in Dublin. I also know it makes for good background music.

I Get a Kick Out of You – Felix Slatkin Ultra-Lounge Volume 3 – Space Capades
The Ultra-Lounge series mines much the same vein as the Ren and Stimpy Music, just from a couple of decades later – lots of 40s and 50s cheese. This is from Space Capades, so there is lots of vibraphone.

Stravinsky: Pulcinella – Scherzino

Symphony No.1, Op.7 ‘Le Poème de la forêt’ in D minor. II. Renouveau

Leave A Tender Moment Alone – Billy Joel
Billy Joel is deeply, deeply uncool. I don’t care, I like it.

Best That You Can Do – Christopher Cross
There is going to be hell to pay when I find out who broke in and planted this in my iTunes library.

William, It Was Really Nothing – The Smiths
You know how I missed out on whole musical trends growing up? One of those trends was The Smiths, the only song I knew was How Soon is Now which I liked. A few years ago I bought a 2CD Best Of The Smiths collection to see what I had missed. And you know what? I hate The Smiths.
How Soon in Now is still pretty cool though.

I Could Be So Good For You – Dennis Waterman
Not sure where this comes from, maybe from my TV Theme collecting days.

Ode To My Family – Cranberries
Everyone of a certain age has either this or Wonderwall by Oasis in their collection.

 Posted by at 2:27 pm
Dec 012008
 

I consider myself a fan of spiders. I knew when I bought a wooden house that I would probably end up sharing it with some eigth-legged friends and I was perfectly OK with that. I do brush up their webs if they get too untidy but generally I leave them alone.

This was wandering around next to my laptop tonight. I am pretty sure it was a white-tailed spider for two reasons: 1: it was skulking around in the middle of the night with evil intent rather than just sitting in a corner like most of my spiders, and 2: it had a white tail.

The bite of the white-tail spider has a bad reputation for making bits of you drop off. I have always figured that this was an exaggeration and wikipedia backs me up. Still, I have been bitten by similarly sized spiders before and did not find the experience pleasant, so outside he goes. I can’t say I will be too upset if he gets eaten by a tui.

I have a new house rule: anything with more than 4 legs must be able to fit on a fifty cent piece.

Sep 202008
 

A man reluctantly lets his teenage daughter take a trip to Paris. As soon as she arrives she a kidnapped (or taken, if you will) by an evil white slavery ring. Luckily she was on the phone to her father at the time and manages to scream out a description of her attackers. Even more lucky – her father is a retired “fixer” for the US government with the skills to take on a small army. He quickly flies to Paris and sets about finding his daughter using the time-honored shoot-everything-in-sight technique.

A bog standard revenge film, Taken does little to distinguish itself except by being a little more brutal than average. The hero kills and tortures dozens of nameless people to get his idiotic daughter back. Sure, “dey were all bad” (read the previous phrase in an Austrian accent) but half the people killed were only tangentially involved. Of course, the police are no help and are actively working against him – the city of Paris should sue the producers for defamation.

In short, not one of Stephen Seagals best films.

What did you say?

It’s a Liam Neeson movie?

No way!

Not recommended unless you really, really like this sort of thing.

May 272007
 

A young girl travels with her mother to a remote military base in the Spanish countryside to live with her stepfather, an army captain. While there, she meets a magical faun who gives her three fantastic quests to carry out. This would be complicated enough, but in the meantime it is 1944 and the Spanish civil war rages on, the fort that they are staying at is full of intrigue, the girl’s mother pregnancy is not going well, and her new stepfather is a sadistic fascist.

Pan’s Labyrinth is the type of magic realism that is not often seen in movies. I guess it resembles older films like The Wizard of Oz and Labyrinth in some ways, but Pan’s Labyrinth is a much darker tale despite featuring such a young protagonist.

panslabyrinthguy.jpgThis guy has excellent hand-eye coordination

The film is also unusual in that the story focuses more on the events in the real world, while the fantasy elements exist more as a subplot. In fact, you could edit out the fantasy scenes altogether and still have a complete story. The deliberate contrast between the sinister creatures the girl must encounter in her quest with the more mundane human monsters she must live with is well done. This is not a story for young children – the film earns its R16 certification with several gory scenes.

Pan’s Labyrinth is one of the better films I have seen all year; highly recommended!

May 202007
 

WordPress 2.2 was released a few days ago, and I thought it was a good excuse to finally update the year old version I was running. The upgrade was complicated by the fact that I store a two extra tables in my WordPress database for my WordMap game, but it all seems to be running OK now. Leave a comment if you notice any problems.

On a related note, WordPress tells me this is my 50th post!

 Posted by at 4:00 pm  Tagged with:
Apr 222007
 

I have just installed Peter’s Custom Anti-spam Image Plugin here (as recommended to me by Aggie). Despite having terrible branding, this plugin allows you to comment on any of my posts without having an account, providing you can prove you are not a spambot trying to post links to porn sites.

Instructions

If you are human making a comment, type the word given in the box provided. You will receive extra credit if you manage to also use the given word in your comment.

If you are a spambot trying to post links to porn sites, don’t type the word giving in the box provided

(If you are a human trying to post links to porn sites, my email address is on my homepage…)

 Posted by at 9:56 pm  Tagged with:
Apr 222007
 

myface.jpg

It’s a Brother MFC-215C, one of those scanner/printer/fax/copier multifunction devices. Its a bit of a jack of all trades but master of none; the included software is pretty terrible (as usual), and for some reason Brother saw fit not to include a USB cable in the box! On the other hand, it was extremely cheap and basically works if you are prepared to mess around a little.

 Posted by at 5:40 pm
Apr 092007
 

It’s Easter, and that means the terrible spectre of Jazz once again haunts the land. These days it seems you can’t move 6 feet during Easter without wandering into an extended guitar solo or quasi-funky drum break. Luckily, the highest concentration of Jazz in Auckland is quarantined on offshore islands, most famously on Waiheke. But recently it has spread to other islands as well.

rakinobeach.jpg

This is one of the beaches on Rakino Island, site of the lesser known Rakino Jazz Festival. I am sorry to say that I was unaware that Rakino Island even existed up until a couple of days ago, hidden as it is behind Waiheke but only a short ferry ride from Auckland. The island is tiny, only about 1.5 km long and less than a km wide, and fairly hilly, but there are still about 60 houses (including some very nice holiday homes) around.

The weather held out for the day, and the music was actually pretty decent. There a worse ways of spending a warm Easter Saturday, and I can look back in the knowledge that almost an entire year before any more Jazz festivals.

Feb 252007
 

Finally a new game for the Wii has been released! Excite Truck is a monster truck racing game pitting you against several nameless, faceless opponents in races set in various locations around the world. All pretense at realism is thrown out the window – the trucks move at insane speeds down narrow branching tracks and jump hundreds of feet into the air. Even better, by running over triggers on the track, the landscape dynamically reforms, usually by having large ramps thrust out of the ground sending your truck soaring.

Most of the strategy in Excite Truck centers around increasing your base speed (already fast enough) with various boosts. You have an unlimited amount of turbo which gives you a good boost, but using it too often can cause your engine to overheat, slowing you down. Using the turbo when your truck first leaves the ground over a jump causes you to rocket into the air at great speed, and while in the air you control the aspect at which the truck is flying. Another large boost occurs if you manage to angle the truck so that it lands with all four wheels at the same time.

The races in Excite Truck are not winner-takes-it-all. You are racing for stars, which can be obtained by a variety of means. Particularly large jumps, stunts while in the air, jumping through hoops, and even taking out the other trucks al give you varying amounts of stars. A good placing at the end of the race gives a large amount of stars but it is perfectly possible to beat a level without winning the race, or even by coming last.

The controls of Excite Truck take a bit of getting used to. The Wii remote is held horizontally, steering (and controlling the truck in midair) is done by turning the controller like a steeling wheel. Once you get your head around not using the d-pad for controlling direction this arrangement works even better than you would expect.

The gameplay is excellent, with the track coming at you so fast that sometimes you have to just let instinct take over, by the time your consciousness has registered the turn coming up you have already passed it. The graphics are very well done as well. Although there are only 5 locations, each one is host to several tracks so there is plenty of variety. The music is dreadful, but you can’t have everything.

Highly recommended.