Skip to main content


Showing posts from September, 2007


So it seems like Firefox is having problems and everyone has been complaining about it a lot. I sure hope they fix it quickly. It's crashing on me constantly when I indulge in my YouTube addiction, and it uses up an ever-increasing amount of memory. A lot of my friends are enjoying Opera, but I just can't bring myself to install a proprietary browser.

I decided to give KDE and Konqueror another shot. I'm actually pretty pleased with it. Although Konqueror doesn't support two of my favorite Web sites, GMail and YouTube, it is very stable and very snappy. Even better, it uses half as much memory. It has a menu option to open the current page in Firefox, which is helpful for the times it doesn't work. This matches what a lot of Mac users do: they use a mix of Firefox and Safari.

On the other hand, something strange happened when I was installing KDE. I accidentally uninstalled the Ubuntu flashplugin-nonfree package. Today, when I went to YouTube, Firefox asked…

Computer Science: Prototypal Match Templates

In object-oriented programming languages, you can subclass an existing class and override a few of its methods. This allows you to take an existing piece of code and tweak it for your own use. However, it's only as granular as the methods that you are overriding. If you want to change one line in a 30 line method, you either have to refactor that 30 line method into several methods (which is the right thing to do if you're in control of the code) or you have to copy the 30 lines and modify that one line (which may be the only thing you can do if you're not in control of the code). Sometimes I actually do both. If I'm using a third-party library that has a 30 line function that I want to change one line of, I copy the whole function into my class, and then refactor it there as if I were refactoring the superclass.

Genshi has a cool mechanism called match templates. I assume XSLT has this too, but since I don't know XSLT, I can't say for certain. Genshi'…

Python: PyWeek

I just finished PyWeek! (Here's the code.) It's a contest where you have one week to write a video game using PyGame. We also used PGU, which is a pretty helpful library for writing video games. This time, my buddy Adam Ulvi participated with me. We took two days off from work and wrote about 800 lines of code. I'm proud to say we created what I think is a pretty impressive and fun game.

I leaned pretty heavily on object-oriented programming this time. I know a lot of people like to talk smack about OOP, but I often find it helpful. The player, the enemies, and even the artillery all subclass a class called SuperSprite that takes care of things like integrating per-frame movement, per-frame animation, collisions, etc. OOP lets me say "these guys should all act exactly the same except in these slightly different ways." Often times, the subclass is no more than a few class-level constants, like a different image. Sometimes they behave slightly differently, …

Python: Useful Utility for PGU's leveledit

I'm participating in PyWeek right now, and I'm using PGU. If you're not using PGU, you can skip this post.

If you're like me, you sometimes get confused about when you're editing the tiles and when you're editing the background. My buddy drew an entire level, and the tiles and background were totally messed up. Rather than redo the entire level, I wrote a little utility to force all the tiles into the background. It's quick-and-dirty, but quite useful when you need it:#!/usr/bin/env python
# Copyright 2007 Adam Ulvi, Shannon Behrens
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of