Google Code Jam

posted: Thu, 17 Jul 2008 09:40 | filed under: / / / | permalink | Tags: , , , , | Comments: 0

Just a friendly reminder to you all that Google Code Jam 2008's qualifying round opens today. Code Jam is an individual programming competition, which lets you compete with a number of languages. Qualifying opens at 9AM Australian time, and you have until that time tomorrow to qualify. Good luck!

Case-insensitive String Replacement (in Python)

posted: Thu, 27 Mar 2008 18:52 | filed under: / / / | permalink | Tags: , , , | Comments: 3

One feature that Python's built-in string replacement facilities does not provide is case-insensitive string replacement. This is a reasonably useful construct (that I use fairly frequently in other languages, such as PHP), which I couldn't find code for after Googling -- so here's some code that does it (licenced under the WTFPL, of course)

import re

def ireplace(self,old,new,count=0):
	''' Behaves like string.replace(), but does so in a case-insensitive
	fashion. '''
	pattern = re.compile(re.escape(old),re.I)
	return re.sub(pattern,new,self,count)
You can also subclass str in order to use it as a bound method:
import re

class str_cir(str):
	''' A string with a built-in case-insensitive replacement method '''
	

	def ireplace(self,old,new,count=0):
		''' Behaves like S.replace(), but does so in a case-insensitive
		fashion. '''
		pattern = re.compile(re.escape(old),re.I)
		return re.sub(pattern,new,self,count)

XKCD Does Python

posted: Wed, 05 Dec 2007 17:05 | filed under: / / / | permalink | Tags: , , | Comments: 3

People who do not code in Python now have no excuse... XKCD has acknowledged Python.

I wrote 20 short programs in Python yesterday.  It was wonderful.  Perl, I'm leaving you.

Hurrah!

NCSS 2008 (First Post)

posted: Fri, 23 Nov 2007 07:19 | filed under: / / / / | permalink | Tags: , , , , | Comments: 2

Well, after a three-months-and-a-week delay, I've finally been invited to be a tutor at this year's National Computer Science School, which is held at the School of Information Technologies at the University of Sydney (in Sydney).

I was a student at the School in 2006, and it was certainly one of the best experiences of my life, and it's great to finally get an opportunity to put back into the School.

I'm certainly looking forward to it. More posts on the topic as it comes.

In related news, I'll be in Sydney from midway-through the first week of January (probably Thursday the 3rd), and leaving roughly on the 14th (if all goes according to plan).