Skip to main content

Navigation

User login

Elsewhere

LinkedIn

Hosted by Sargasso Networks
World of Goo Fans!

Java Preferences using a file as the backing store

June 18, 2009 by davidc

java.util.prefs is great. Since it arrived, I've not had to worry about storing configuration in property files, or where those files should go. It abstracts away any platform differences and stores the preferences in a suitable place for the platform, e.g. in the registry under Windows.

I recently received a request to allow an application to have its configuration stored in a file instead of the registry. The user wanted it to run on any computer from a flash drive, with the configuration moving too. You can easily change the Preferences implementation using the java.util.prefs.PreferencesFactory system property, but the Sun JVM only ships with the platform-specific Preferences implementation, i.e. WindowsPreferences under Windows. I therefore needed to create my own Preferences implementation, which is detailed in this article.

Qmail looping messages around the same server

June 13, 2009 by davidc

I've been investigating why qmail has been looping some messages through the same server. Even though MX records are configured correctly, the headers indicate that it is been sent back to the same server repeatedly until it reaches the hop limit.

IPv6 Source Address Selection on Linux

May 11, 2009 by davidc

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.

RIPE EIX Election

May 7, 2009 by davidc

Andy Davidson is up for election as co-chair of the EIX working group at RIPE and I would invite you to vote for him.

Due to the nature of the RIPE community, it is NOT necessary for you to be a RIPE NCC member in order to vote, merely to be an interested member of the RIPE community. Simply e-mail eix.ripe@gmail.com with your name, organisation and choice of
candidates. Please do so before 10am UK time (11am European time) today. Note that, as it is a STV system, it is not necessary to vote for all three. I recommend voting only for Andy.

The election invitation, along with Andy's address, is below.

Singleton Java application

April 28, 2009 by davidc

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

April 28, 2009 by davidc

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

Browsing URLs and opening files

April 22, 2009 by davidc

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

April 20, 2009 by davidc

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. There was the job and the girl. It was the job, of course, writing copy when you should be writing plays, but you couldn't get rid of the job because the job was bread and alcohol, so you got rid of the girl instead. When you added it up later you saw that you had gained nothing but had lost a great deal instead.

ayTemplates released, 7 years too late

April 18, 2009 by davidc

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.

There never was a public release of ayTemplates, despite being written in 2002 and being improved through 2004. Around that time 99dogs finally gave up the ghost, and I stopped writing PHP professionally, so it never saw production. I occasionally still get enquiries about it though, so here in 2009, I'm finally releasing it. It's over there, along with its documentation.

Dynamic bitmap fonts

April 14, 2009 by davidc

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.