Apple’s mod_bonjour is broken in Snow Leopard, so I fixed it.
I was playing about with Apache on my iMac and I noticed a little file tucked away in /etc/apache2/other called bonjour.conf. Intrigued I set about figuring out what it was for.
This file had some directives relating to an Apache module called mod_bonjour. The purpose of which is to register URLs with Apple’s Boujour service. This service lets systems and services publish their existence on a local area network so other systems and applications can find them without configuration. Boujour is just Apple’s marketing speak for Zeroconf style networking. It is also known as multicast DNS and is common on Linux and Apple systems.

Safari on MacOS even has a Bonjour menu that displays services or devices that are advertising themselves via the Bonjour service. An example of this is my QNAP NAS. I can always easily access the Admin interface of my NAS (and other services the NAS provides) because it advertises itself with Bonjour.
I thought that using Bonjour would be rather handy for advertising some web applications I had configured on my iMac to other systems on my home network. So I added them to the bonjour.conf configuration file like so:
RegisterUserSite customized-users
RegisterResource “Confluence” “/confluence”
RegisterResource “TeamCity” “/teamcity”
Unfortunately after restarting Apache I was dismayed to discover that only the last RegisterResource directive seemed to be working (TeamCity), as it was the only resource showing up in the Bonjour menu in Safari.
However after a quick search for mod_bonjour with Google I discovered two posts detailing the problem. There is a bug in mod_bonjour.
Joe Maller found the bug and supposedly reported it to Apple in 2007, and Chuck Houpt even created and released a patch for the Leopard release of Mac OS X.
Now I’m running Snow Leopard so I didn’t want to just use the patched binary Chuck provided, so I set about patching the Snow Leopard version of this module. Fortunately Apple provide the source code to this module on their open source site. So I took what appears to be the code from Snow Leopard, applied Chuck’s patch and produced a version for Snow Leopard.
In order to share this updated code with the wider Internet I’ve created a GitHub code repository for it. In order to build this code and update your Mac you will need the Apple Developer Tools installed.
Azure Table Storage, what a pain in the ass.
Lately I’ve been playing with Microsoft’s Azure service. Tonight in particular I was attempting to use the Table Storage service. Table Storage is a simple REST based object persistence system. Microsoft have wrapped this in the ADO.NET Data Services API. So it looks fairly full featured. However it is not. At almost every turn I have ended up bashing my head against a Table Storage limitation. Debuging these problems has been a bit of a nightmare.
The things I have learned are as follows.
Development Table Storage is Arse
The local Development Table Storage service (based on top of SQL Server Express), has limitations and idiosyncrasies that the full cloud hosted service does not, as outlined by Microsoft.
In particular the fact that “in development storage, querying on a property that does not exist in the table returns an error” caused me a bit of a problem. When my table was empty I could not execute simple queries such as:
var q = from v in context.CreateQuery(VehicleTableName) where v.Id == id select v;
Doing so with an empty table would generate cryptic and unhelpful exceptions with messages along the lines of “one of the request inputs is not valid”. With some furious googling I discovered that, with the development table storage service, one has to incant the following on service start up to ensure that the table storage knows about the structure of your objects.
var query = from x in context.CreateQuery(VehicleTableName) select x;
var l = query.ToList();
var v = new Vehicle();
context.AddVehicle(v);
context.SaveChanges();
context.DeleteObject(v);
context.SaveChanges();
This insert/delete voodoo ensures that the SchemaXml column of the TableContainer table for my “Vehicles” table is populated with the appropriate XML definition of my Vehicle class. You have to do this for each of your tables/classes every time you start up your service. This is idiotic to say the least.
You Can’t Store Classes with Decimal Members.
It took me a while, after many more “one of the request inputs is not valid” style exceptions to figure out that my Vehicle class was being rejected because it had a property, Price, of type Decimal. That type is not supported by Table Storage. I don’t think this is documented anywhere.
DatesTimes Must Be UTC.
After yet more “one of the request inputs is not valid” exceptions, I guessed why the following was failing.
var q = context.CreateQuery(VehicleTableName)
.Where(v => v.PartitionKey == Vehicle.Partition && v.ExpiryDate >= DateTime.Now.Date);
I needed to add the magic UTC characters so it read as follows.
var q = context.CreateQuery(VehicleTableName)
.Where(v => v.PartitionKey == Vehicle.Partition && v.ExpiryDate >= DateTime.UtcNow.Date);
So my journey so far into Azure’s data storage APIs has been somewhat less enjoyable than I had otherwise hoped. I just hope my luck improves as I delve deeper into its mysteries.
Is Iron Man made of Lego?
I was re-watching Iron Man recently and noticed something interesting. During Iron Man’s first “boot up sequence”, in the “terrorist” caves of Nowhereistan, some butchered C code is displayed on a faked up laptop screen.

The code displayed on screen, although missing some syntactically important characters such as semi-colons, is actual valid C source code. So valid in fact that I wondered where it came from.
After a quick Google I found it. This code is in fact as follows:
send[0] = 0x65;
send[1] = 1;
send[2] = 3;
send[3] = 5;
send[4] = 7;
send[5] = 11;
if (rcx_sendrecv(fd, send, 6, recv, 1, 50, RETRIES, use_comp) != 1) {
fprintf(stderr, "%s: delete firmware failed\n", progname);
exit(1);
}
/* Start firmware download */
send[0] = 0x75;
send[1] = (start >> 0) & 0xff;
send[2] = (start >>
& 0xff;
send[3] = (cksum >> 0) & 0xff;
send[4] = (cksum >>
& 0xff;
send[5] = 0;
if (rcx_sendrecv(fd, send, 6, recv, 2, 50, RETRIES, use_comp) != 2) {
fprintf(stderr, "%s: start firmware download failed\n", progname);
exit(1);
}
/* Transfer data */
addr = 0;
index = 1;
for (addr = 0, index = 1; addr < len; addr += size, index++) {
The code above comes from a firmware downloader for the RCX (a programmable, microcontroller-based Lego brick), written in 1998 at Stanford University by Kekoa Proudfoot. You can get the full source file here and it is distributed under the Mozilla Public License. This is the same license used by Firefox and many other Open Source software products.
The sequence in the film in which this code appears suggests that the code is either being downloaded as firmware to the Iron Man suit or being used to upload firmware to an RCX Lego brick that is somehow involved in the operation of Iron Man.
So it appears that Iron Man is either powered by Open Source software or made of Lego. I’m not sure which is cooler.
MSBuild, assembly dependencies and the GAC
Today, while doing some .Net development I noticed something about MSBuild that is really annoying. I’ve seen his before but didn’t know the reason behind it. Now I do and it is a little frustrating.
If you have assembly A that depends on assembly B that depends on assembly C and assembly C exists in the GAC (Global Assembly Cache). When assembly B is copied into assembly A’s “bin” directory during build, assembly C is not copied, even if you specify that assembly C is a “private” (copy local) dependency of assembly B.
The problem is that by default MSBuild’s ResolveAssemblyReference task will not copy referenced assemblies that are in the GAC to the build output directory unless the referenced assembly is specifically tagged as “private” by the build project being built.
So even though assembly A doesn’t directly reference assembly C in its code, it only uses C through the intermediate dependency B, you still need to add C to A’s referenced assemblies set for C to be copied into the build output of A.
There is a discussion of this issue here, on Microsoft’s developer forums.
Telestream Screenflow e-Commerce FAIL & Twitter
Recently I had a need to create a screencast to help my father learn how to use his new Mac. I’d seen Telestream Screenflow used in the past and from that, and a little play with the trial version, I decided I’d purchase the app for my Mac.
Although Screenflow is a bit expensive at 99USD, it has a lot of cool features, so I was all prepped and waving my credit card around ready to buy. Unfortunately when I went to Telestream’s eSellerate powered store it didn’t even list the application for sale.
Epic sales FAIL.
The chaps at Telestream however had made the smart decision to list their Twitter name on their site (@screenflow). So I tweeted a little note about how their store was broken when I had wanted to buy and that they had lost a sale.
I then went on to use Snapz Pro X, which I already own, to make my little screencast.
The next day, @screenflow tweeted me a little direct message asking for my email address, which I provided. Lo-and-behold, in response they send me a coupon code for a 100% discount for my troubles. Nice.
Thanks Telestream, that’s what I call customer service.
Programmer Humour.
Call:
How do I update controls on my UI thread from the Asyncronous Delegate? I understand it’s not safe to just try to update it directly from the asynchronous thread, but I need to figure out how to update it somehow. Specifically I need to increment a ProgressBar and update text in a Label.
Thanks,
Michael C.
Response:
My name is Tyrone Hernandez. I grew up on the streets, so I’m familiar with this kind of shiznit. I am down with this, and I’m going to keep it real by top-posting.
In my hood, I have a homie named Shaniqua and some times she calls me on the phone in an asynchronous fashion. Now I’m hip to her jive, so I don’t wanna just hang up. If I feels like talkin to Shaniqua, I talk to her. If not, I use my power of “Control” to check “IsInvokeRequired” and if it is, I call Control.BeginInvoke() to upgrade my progress bar.
Well, I’d be likin’ to talk more, but my crack dealer is here so I’m going to call some of his methods. Peace out!
Made me laugh. And he’s correct. Found, here.
The Slip
Speaking of good music and @Trent_Reznor, you should totally download The Slip. Nine Inch Nails are releasing all their music as totally free downloads (under creative commons licenses) these days.
Justice
Thanks to @trent_reznor‘s blip.fm play list today I discovered Justice. If you’re at all into acts like Daft Punk I’m sure you’ll dig this album.
Blast from the past.
While saving a document in Word 2003 the other day, my colleague Phil witnessed Word spit the dummy and display this dialog.

Format what?
It appears to be some sort of vestigial error dialog from Word 6.0 for Windows 3.1. Check out the awesome ASCII art bullet points and encouragement to format another floppy disk.
Sure I’ll just whip out and pop in a 3.5″ floppy and do that right away.
Essential Mac Add-on
I just found an essential MacOS X add-on.
One of the things I find annoying with the Mac is the fact that there are no keyboard shortcuts for window management beyond minimizing and hiding an application’s windows.
My desktop screen is larger in both size and resolution than my MacBook’s built in display. So when I’m travelling often I’ll open up an application, say iTunes for example, and the window will be larger than my screen can accomodate. The borders of the window and the resize grab handle will be off screen with no way for me to mouse to the right place and resize the window to fit.
Enter MercuryMover. This System Preference Pane provides customizable keyboard shortcuts and a nice little overlay GUI for manipulating windows with the keyboard. Now I don’t mind paying the $20 to buy this app because it is damn useful, but this sort of feature should really be built-in to MacOS X. Hopefully Apple will do that one day. I don’t hold out much hope though.
