IPv6 Source Address Selection on Linux

Submitted by davidc on Mon, 11/05/2009 - 10:36

Sometimes it is desirable to have the outgoing IPv6 address on an interface selected deterministically. All else being equal, Linux will default to using the latest address added to the interface as the source address. This is generally not what you would expect or want. This article describes how to influence the source address selection under Linux.

Singleton Java application

Submitted by davidc on Tue, 28/04/2009 - 03:12

Sometimes it is necessary to have a Java application that can only have one open instance, but still is able to handle command-line arguments (for example, requests to open a file). For native applications, this is easy to accomplish using native methods, but with Java the facilities are limited. This article describes a method to accomplish the goal using pure Java, with java.nio locking and local TCP sockets. It also explains how and why this is unnecessary under Mac OS X.

You and I

Submitted by davidc on Tue, 28/04/2009 - 02:33

I explain quietly. You
hear me shouting. You
try a new tack. I
feel old wounds reopen.

You see both sides. I
see your blinkers. I
am placatory. You
sense a new selfishness.

I am a dove. You
recognize the hawk. You
offer an olive branch. I
feel the thorns.

You bleed. I
see crocodile tears. I
withdraw. You
reel from the impact.

- Roger McGough

Browsing URLs and opening files

Submitted by davidc on Wed, 22/04/2009 - 14:50

Java 1.6 added a new class, java.awt.Desktop, that provides handy methods to launch a web browser to a given URL, or open a given file. However these methods are not available under earlier JREs. This article provides a cross-platform surrogate class that uses the Desktop methods where possible, and falls back to platform-dependent methods if not. It uses reflection extensively to avoid linking problems. It also provides additional *AndWarn() methods to show a JOptionPane error message upon failure.

From Dawn to Dusk

Submitted by davidc on Mon, 20/04/2009 - 03:55

That was it, he knew, the damn job. You went along doing the best you could, and one day you realized that you were wasting time and not doing anything at all. There were so many things you had wanted to do, so many you still wanted, and you saw clearly that you weren't doing any of them and never would, and you grew so frantic thinking about it, you could feel the panic forming inside you. You saw how immense the world was, and you realized that you were so limited it was all going to waste around you, and you felt that you had to do something quick before it was too late.

ayTemplates released, 7 years too late

Submitted by davidc on Fri, 17/04/2009 - 23:44

So I'm celebrating the 5-year anniversary of my leaving the 99dogs crapfest by finally releasing ayTemplates. ayTemplates is a PHP extension written in C, designed for lightning-fast execution of standard template operations. At 99dogs, we were using a derivative of FastTemplate for some very heavy templating, as we had a team of web designers working independently from the programmers. Doing all this in PHP with regular expressions was insanely slow and inappropriate, so ayTemplates was born.

Dynamic bitmap fonts

Submitted by davidc on Tue, 14/04/2009 - 16:48

For the recent April Fool's joke at goofans.com, I wanted to exactly reproduce the look and feel of the in-game computer in World of Goo. This included reproducing the font used with some clever CSS/DHTML. This article describes a reusable, efficient, client-side DHTML bitmapped font library.

Since I put in a tremendous amount of work for an April Fool's prank, I decided to publish this code here in case anyone else has a need for bitmapped fonts. It is released under the MIT license.

Oh look, I made a blog

Submitted by davidc on Wed, 01/04/2009 - 14:16

Right, don't even think about mocking me, but I'm starting a blog. Not to talk about the futility of life and how pretty girls hate me (unless I get really drunk), but because I'm sick of all my wasted work. I seem to be constantly writing code or fiddling with things where the result is either only used in one place, or is used once and thrown away, or simply never gets finished. Some of this I'm convinced will be useful to others, or even to myself in the future.


Submitted by davidc on Fri, 18/03/2005 - 07:23

"niggadogg.com" was a website I wrote to poke fun of the infamous "da-drew", who would always come on IRC and spout a bunch of nonsensical pseudo-ebonics. It generates the kind of sentences that he might have said.

This was actually an interesting experiment in first-order Markov chains, where a sentence is constructed using word-sequence probabilities - the next word is based taking the preceding word and choosing a word based on its probability of appearing next in the sample corpus (around 4,500 lines of "sanitised" da-drew quotes from IRC).