My best hacks

if I don't say so myself

Author: Dean Hall

LiNewt

Date:1995/08/28

This is my top hack because it was my first. My first hack. My first perl script. My first time sharing code I'd written. LiNewt was a little perl script that slurped emails from an Apple Newton connected to the PC's serial port, formatted them per RFC 821, and sent them out to the ineternet via smtp. This hack gained a little noteriety. A better perl hacker than I suggested a few improvements. I let him maintain the code thereafter.

PyMite Native Functions

Date:2002/10/??

While making PyMite, I needed a way to call native C/assembly code from a Python program runing in my PyMite VM. I know and respect SWIG, but it didn't really fit the embedded systems that PyMite targets. Likewise, I avoided JNI like the plague.

Instead I created a native function interface of my own design. The function is defined in python syntax in a python source file. The native code is then embedded in the docstring of that function. The body of the python function is, simply, pass. I use a python script in the compilation of the VM to aggregate the native code and I provide some C macros to simplify the process of accessing the function's arguments. All told, it makes coding native functions dirt simple for the user (by user, I mean the programmer-user. What? You thought I meant end-user? ha!)

I like this hack because it does the work of two huge tools, SWIG and JNI, but for a tiny 8-bit embedded target. I like that it repurposes the Python docstring and makes an otherwise difficult task very easy.

Room Detection

Date:1996

My EECE degree required that I take the CIS course, Software Engineering. Luckily, I got it during a semester where the professor was a robotics afficionado. Our project for that semester was to write code, following SE techniques, to make a robot navigate an artifical floorplan, map the rooms and stop when the entire floorplan is covered.

My little contribution to this team endeavor was an algorithm that detects when a robot is in a room (rather than a hallway). I like this hack in particular because of its simplicity and its application of something I learned in Calc II. The robot has a 360-degree ring of ultrasonic range-finding sensors. By summing the value of all these sensors, I, in effect, calculated the area of the space surrounding the robot. Then, I established threshold between typical hallway areas and typical room areas. In operation, the algorithm ran as a function that was called periodially. It calculated the local area and returned a constant that represented either "room" or "hallway".

Bogl

Date:2005/08/30

While working at Motorola, a coworker invited me to play Boggle online during the lunch hour. He played Boggle often and he beat me about 4 out of 5 games on average. So I sought a way to, um... even the score.

I whipped up the bogl.py Python script that runs via cli, takes a dictionary and the boggle board as input and produces a list of Scrabble-legal words as output. I like this hack because I think the algorithm I use is straightforward and efficient. The algorithm iterates over each letter on the board and uses it as the starting point. From the starting point, the algorithm recursively searches the neighboring letter and will stop at the first letter that does not for a word in the dictionary. Thus, the 7-way, tree-shaped search space is pruned at the earliest opportunity.

I used the script once during a lunchtime game of Boggle and "found" something like 179 words in the puzzle. I beat my coworker by five-fold number of points that game and had a good chuckle when I heard him gasp at my sudden "improvement." I fessed up quickly, but it made my day.