Code I'm proud of
Over the years, I have written a lot of code. However, most of the cooler stuff is owned by the companies I developed it for. Of what remains, I've posted some of the code I'm particularly proud of here.
BigFraction
BigFraction is a Java class I developed that represents a fraction as a ratio of two BigIntegers, reduced
to lowest terms. Because it uses BigIntegers, it will never overflow, no matter how large the numerator or
denominator is (unless you overflow the available memory of course). This also ensures that the results
of division operations will never encounter round-off errors. I developed the class while I was working on
several Project Euler exercises. It was a fun opportunity to develop
a reusable class that incorporates mathematics and principals of numeric methods that I rarely get to use
in practice, particularly when converting to or from float or double values.
- BigFraction.java
- BigFractionTest.java - JUnit test cases
ImageSizer
ImageSizer is a utility I wrote for the purpose of making a nice background image for a multi-monitor
display. Aside from just resizing and cropping, it also removes the part of the middle of the image,
so that it will appear to be "behind" the gap between the two windows. I have written very
detailed documentation of the tool, including diagrams, in a blog post.
- Main.java
- ImageSizer.java
- ImageSizer.jar (compiled version)
PHP gradient generator
The PHP gradient generator allows me to dynamically generate a gradient image, which I use extensively
in the backgrounds of images on my photo album pages. I recently updated the generator to add support for
dithering, which I described
in detail in a blog post.
Twitter status update
This is a PHP class I wrote for the sole purpose of updating my Twitter status programmatically from
PHP. I use this whenever I make a blog post, to automatically tweet a link to the post. This involved
oAuth authentication. A blog post covers how
to obtain the oAuth keys.
QuickReplace
QuickReplace is a web app I wrote to
help myself out of the many cases I find myself in as a programmer, where I am making repetitive,
tedious changes to a block of text. Changes that are just a little too complex for a simple search/replace.
It’s really simple. Just paste text into the first big text area, and then it will be filtered and
displayed in the lower text area. There are three types of filters: text that is prepended or appended
to each line; a simple search/replace (with \n and \t allowed), and a full-on regex substitution. And
everything is updated as you type it, so you can see the effects of the filters as you enter them.
(This really helps when you haven’t written a regex in a month or so.)
Everything is done in Javascript so the page is completely self-contained—you can view source and save
a local copy if you wish. (It does require an internet connection, as it uses Google-hosted jQuery.)
Album Thumbnail
This is the code I use to generate the collage thumbnails that are used in the photo albums on this
site. Given four images, it will create a collage thumbnail containing all four images. More information
can be found in the documentation.