Pages

Monday, July 24, 2006

ICFP contest done

My team and I participated in this year's ICFP programming contest - a weekend of very little sleep and lots of programming. This was the first year our team (i.e. The Black Knight Always Triumphs) took part.

We were amazed at the effort the judges must have gone through to prepare the problems. My favorite problems where writing the virtual machine that ran the problems and hacking into "user accounts" using their stripped down version of Basic which uses Roman numerals for line numbers.

We expect to finish under the first third of participants (that made it to the scoreboard) and we'll definately be back next year.

Wednesday, July 12, 2006

del.icio.us importing

I wanted to change my del.icio.us username. You aren't allowed to do this directly, but you can export your links to an html file and try to import it back into a new account. Unfortunately their import function can't parse the data generated by their export function. Strange. (apparently fixed now) Luckely they have an open API (and a whole bunch of third-party tools).

So with the help of BeautifulSoup I simply parsed the exported html and used pydelicious to post it back into delicious. Like So:

from BeautifulSoup import BeautifulSoup
import pydelicious
from itertools import count

def main():
soup = BeautifulSoup(file("export.htm").read())
user = "user"
password = "pass"
items = soup.findAll("a")
print len(items)
for item, n in zip(items, count()):
href = item["href"]
tags = item["tags"]
title = item.string
add_date = item["add_date"]
last_modified = item["last_modified"]
print n,
try:
pydelicious.add(user, password, href, title, tags=tags, dt=add_date, replace="yes")
except Exception, e:
print e

Ah, I love Python.

While writing this post I ran into some del.icio.us experiments, which might be useful to someone. And a follow-up with very pretty graphs.