By David, on February 28th, 2009
If you’ve had a dog you’ll know how they often twitch and move their limbs in their sleep. Well, this dog is like that but on a whole other level.
Must have scared the crap out of the owners the first time she did this.
How about sleep barking?
Sleep running in circles
Imagine if the dog was . . . → Read More: Sleep walking dog… or should that be sleep running?
By David, on February 28th, 2009
Firefox still tends to be a bit of a memory hog over an extended period of time, even though the latest major version (3) has made massive memory usage improvements over previous versions.
This tweak will make sure Firefox behaves more like standard Windows applications when it comes to being minimized, as in freeing up the memory . . . → Read More: Improve Mozilla Firefox 3 memory usage
By David, on February 28th, 2009
A few months ago I posted a little query about finding duplicate rows in a database table. I’m revisiting this because I helped out Doogie with a similar query last night but with some complications.
Let’s start with the original simple scenario of checking duplicates in a single column.
Some example data, a Users table:
+----+----------------+
| Id | Email |
+----+----------------+
| 1 | joe@bloggs.com |
| 2 | joe@bloggs.com |
| 3 | joe@bloggs.com |
| 4 | jane@doe.com |
| 5 | jane@doe.com |
| 6 | john@doe.com |
+----+----------------+
You can see that joe@bloggs.com and jane@doe.com have been duplicated. This could have been prevented by putting a unique index on the Email column.
So to find what emails have duplicates in our table:
Continue reading Finding duplicated data across one or more columns in a database table
By David, on February 27th, 2009
Land for Bags, . . . → Read More: Where’d I get my bag?
By David, on February 25th, 2009
How cool is this poster? (Click for . . . → Read More: All Blacks “Of This Earth” Poster
By David, on February 25th, 2009
By David, on February 7th, 2009
Most thumbnail-generation solutions will shrink the original down while maintaining aspect ratio.
Usually you specify the maximum height and width of the thumbnail, e.g. 150 x 200.
However, if your original image’s aspect ratio is different to the maximum thumbnail dimensions, you will end up with dead space vertically or horizontally (shown in green in the illustration). This can be quite an eyesore when displaying thumbnails in a grid.

I’ve got an algorithm that will automatically crop the image either horizontally or vertically to then match the thumbnail aspect ratio, so you end up with the thumbnails all being the same size even though they may be coming from originals of wildly different aspect ratio.
In the illustration, you can see that the image is scaled down and fills all the available thumbnail space, showing the parts in grey from the original that were cropped out.

The algorithm does the cropping before the resizing. It takes the width and height of the original image, and the width and height of the desired thumbnail. It will return the width and height that the original must be cropped to, to match the aspect ratio of the thumbnail. Continue reading Creating thumbnail images with automatic cropping and maintaining aspect ratio