December 27, 2007

Migrate from Gallery 2 to Flickr

Posted in Misc at 02:04 by graham

I have recently moved all my photos from a Gallery 2 instance I ran myself, to Flickr. This means I don’t need to keep my Gallery2 install up to date, it frees up lots of disk space on my server, and allows me to more easily share pictures with friends and family. Here’s how I did it:

Read the rest of this entry »

December 19, 2007

Keep your unit testing lazy

Posted in Software at 19:49 by graham

Oscar Huseyin, via JavaLobby, has an interesting post on how much unit testing is good:

Over the years, l’ve read lots of commentary, white papers, best practice papers, books on the topic of TDD. I’ve heard the rant of many TDD evangelists who preach about how total code coverage brings you closer to code quality perfection and how you’ve failed when you’ve not been able to achieve these goals. Sure, this is an extreme example of evangelical preaching, where in actual fact, most of these individuals commonly drum down their hard line views of testing by using words like “pragmatism” and statements like “do what works best”. But, why do l feel as if I’ve failed if l have not got 100% code coverage? It’s because l, to some degree, shared some of the religious views about testing.

Read the rest of this entry »

December 18, 2007

Non blocking console input in Python and Java

Posted in Software at 21:42 by graham

Update Sep 2011: If you’re using Google’s Go Lang see Non blocking console read in Go. Thanks Ostsol


Heavily updated 9th January 2008: This post was originally entitled Non blocking console IO is not possible. Two helpful comments helped me see the error of my ways. Many thanks to ‘schlenk’ and ‘Bob’ for the help. Non blocking console IO is possible, it just isn’t (easily) portable. Read on to find out how.


I have been doing some programming exercises in Python, Java and ActionScript (Flex), using this list from Prashant N Mhatre. The first exercise sounds simple on the surface:

Display series of numbers (1,2,3,4, 5….etc) in an infinite loop. The program should quit if someone hits a specific key (Say ESCAPE key)

Displaying a list of numbers in an infinite loop is trivial, and stopping on Ctrl-C is trivial, but stopping on a key of your choice (let’s use ESC), makes the problem much more interesting.

By default the console on Linux and Windows is buffered. It does not send you character data until the Enter key is pressed. In Python the raw_input method will block until it gets input. In Java you can test the characters available, non blocking, using System.in.available(), but this still doesn’t fill up until Enter is pressed. There are two ways to solve this:

Read the rest of this entry »

December 12, 2007

XMPP in your browser: Flex 2 with XIFF

Posted in Software at 23:40 by graham

An entry about using the XIFF API to get your Flex application talking XMPP. If you don’t know what I’m talking about no need to read on really.

Some definitions

  • XMPP is an open protocol for instant messaging, that runs the Jabber network and Google talk.
  • Flex 2 is a programmer-friendly way of developing Flash applications, using ActionScript 3, which looks a lot like Java.
  • XIFF is an ActionScript 3 API for XMPP.

If you put those three items together you get, yes, a paradigm shift in web based application development. But let’s not get fancy just yet (a later blog post might wax lyrical about the future of web apps), for now here are some recipes for doing just about anything with XMPP, ActionScript 3, and XIFF.

Read the rest of this entry »