Variable argument lists in C#


These would be called varargian functions in C… It turns out they’re possible with C#. Check it out:

    using System;
    using System.Text;
    namespace varargs
    	class Class1
    		static void Main(string[] args)
    			Console.WriteLine(printf("This %s a %s string", "is", "format"));
    		// The worst printf ever written
    		static string printf(string format, params object[] args)
    			int idx = 0;
    			bool insideFormatChar = false;
    			StringBuilder result = new StringBuilder();
    			for(int i = 0; i < format.Length; i++)
    					if(format[i] == '%') result.Append("%");
    					else result.Append(args[idx++].ToString());
    					insideFormatChar = false;
    				else if(format[i] == '%') insideFormatChar = true;
    			return result.ToString();

Who would you send to dog island?


I found the following whilst surfing trying to find out what on earth the lyrics to “Who Let the Dogs Out” by the Baha Men is talking about…

“…For years human beings have owned other human beings. This was called slavery. During times of slavery, slave owners talked about the difference between treating their slaves in a “good” way and in a “bad” way. The issue was never, should we or should we not own slaves. For a more detailed discussion of this notion, see Valerie Martin’s book Property. You’ll find it to be an eye-opener.

The same issues apply to us, in this 21st century. We have conditioned our lovely canine friends to live under our rules. They are used to it, yes. They have learned to love us anyway, yes. But it is not right, no. Dogs should live free, should live lives unfettered by humiliation due to forced public defecation and having to walk on a leash.”

Should we send you to Dog Island?


Back in the land of the bandwidth


After a six month trip in the land of the 56k modem, I have DSL again. This is after Telstra kindly agreed to increase the range of the ADSL kit their using so that I could get coverage. How nice of them to let me buy a product!


DSE WebCam with Microphone

Bob Edwards picked up a Dick Smith web cam a little while ago. It was interesting because we’ve both been looking for OV511 based web cams for a while after I picked up a nice on on holidays in Perth — I haven’t been able to find a supplier since. This new camera is an interesting one for a couple of reasons:

  • It’s OV519 based
  • It speaks JPEG natively (and therefore doesn’t work with video4linux)
  • It’s cheap (about $60 Australian)
  • The driver only works with Linu 2.4 kernels at the moment

So here I am on a Sunday evening, in my office at ANU fiddling away. I’ve had this camera on my TODO list for a little while, so I have some code already. The basic approach I am taking is to take the 2.4 driver which outputs JPEG files, and write a little user space daemon which decompresses these, and then reinserts the images into the video4linux system so that other applications can still use the camera.

I’m standing on the shoulders of giants here, because there is already a driver, there is sample code for the reinjection (from the dude who wrote Motion), and JPEG decompression still pretty well understood. So far I have a user space application which reads a frame from the camera and sticks it in a file on disc. I just have to solve the reinjection problem now…

The images aren’t too amazing. Here’s a sample:

It’s pretty hard to focus at the moment because it’s getting dark outside. This might not be the best image quality the camera is capable of…

Playing with vloopback, the following sites are of interest:

To be continued…


The pain of productivity


So, with my ISP offline, a bunch of my distractions for the day just went away. This is a good thing, because it means that I have to get more work done. I’ve been feeling a little how Joel describes recently. I suspect that the problem for me is that the Open Source world doesn’t seem to be moving as fast as it was a couple of years ago, and the honeymoon is over to a certain extent.

I’m kinda slipping into the daily grind at work as well. It’s easier to predict now what a given day will bring, which reduces the excitement one can throw at a new problem.

I think part of the problem for me is that I entered the industry in 1996 — during the recent unpleasantness called the “dotcom”. This is my first industry downturn, which make it a little harder than it actually was. Now that things seem to be picking up a little, hopefully the world will get a little more fun again.


Read me


I have to close my browser, but want to remember to read these:


libmplot tweaks


For my PhD I’m playing with methods of determining what compression algorithm is applied to raster image data algorithmically. For that I needed to generate a bunch of test images. I’ve put some performance enhancements into the CVS version of libmplot to assist with that.


New laptop (an IBM R51)


I’m writing this on my new IBM ThinkPad R51, which arrived about half a week before they said it would, and only about 10 days after I ordered it. I thought that was pretty impressive service for a model so new that they didn’t have any of them in the country yet when I ordered it. Anyways, some dirt on the machine… It’s an 1829-EBM, which is distracting to anyone who has two young children — EBM is short for “Expressed Breast Milk” to parents of young children. It’s got a 1.7Ghz Pentium M (Centrino), a gig of RAM, and a 60 GB hard disk. There’s 802.11a, 802.11b, and 802.11g, all done with an “IBM miniPCI card, which reports itself as a “Atheros Communications, Inc. AR5212 802.11abg NIC” in the lspci output below:

    challenger:/home/mikal# lspci
    0000:00:00.0 Host bridge: Intel Corp. 82855PM Processor to I/O Controller (rev 03)
    0000:00:01.0 PCI bridge: Intel Corp. 82855PM Processor to AGP Controller (rev 03)
    0000:00:1d.0 USB Controller: Intel Corp. 82801DB (ICH4) USB UHCI #1 (rev 01)
    0000:00:1d.1 USB Controller: Intel Corp. 82801DB (ICH4) USB UHCI #2 (rev 01)
    0000:00:1d.2 USB Controller: Intel Corp. 82801DB (ICH4) USB UHCI #3 (rev 01)
    0000:00:1d.7 USB Controller: Intel Corp. 82801DB (ICH4) USB2 EHCI Controller (rev 01)
    0000:00:1e.0 PCI bridge: Intel Corp. 82801BAM/CAM PCI Bridge (rev 81)
    0000:00:1f.0 ISA bridge: Intel Corp. 82801DBM LPC Interface Controller (rev 01)
    0000:00:1f.1 IDE interface: Intel Corp. 82801DBM (ICH4) Ultra ATA Storage Controller (rev 01)
    0000:00:1f.3 SMBus: Intel Corp. 82801DB/DBM (ICH4) SMBus Controller (rev 01)
    0000:00:1f.5 Multimedia audio controller: Intel Corp. 82801DB (ICH4) AC'97 Audio Controller (rev 01)
    0000:00:1f.6 Modem: Intel Corp. 82801DB (ICH4) AC'97 Modem Controller (rev 01)
    0000:01:00.0 VGA compatible controller: ATI Technologies Inc Radeon R250 Lf [Radeon Mobility 9000 M9] (rev 02)
    0000:02:00.0 CardBus bridge: Texas Instruments PCI4520 PC card Cardbus Controller (rev 01)
    0000:02:00.2 FireWire (IEEE 1394): Texas Instruments: Unknown device 802a (rev 01)
    0000:02:01.0 Ethernet controller: Intel Corp. 82540EP Gigabit Ethernet Controller (Mobile) (rev 03)
    0000:02:02.0 Ethernet controller: Atheros Communications, Inc. AR5212 802.11abg NIC (rev 01)

Let’s work through the features of the laptop, and I’ll tell you if they work yet…


The machine has an amazing 1400 x 1050 LCD display. I’ve been used to the micro-laptops that I’ve been using for the last few years, and this is the first laptop I’ve ever owned which can do more than 1024 x 768. It’s taking a little time to get used to my eye having to move horizontally to see an entire line of text. The display is amazingly crisp, and X worked almost instantly (Debian Unstable) without any fiddling. I’m using version 4.3.0.dfsg.1-1 of XFree86, where I suspect that the dfsg is a Debianism. I’ve put the XF86Config-4 file online for other people’s reference. I used the ATI driver.

Xine produces very nice output in fullscreen mode — it’s a lot nicer than my Grundig TV.


I use 2.6, so I’ve got ALSA configured on the machine. This machine uses the same sound driver as the Dell D400 I was using before this machine. Select “Intel i8x0/MX440, SiS 7012; Ali 5455; NForce Audio; AMD768/8111” from the ALSA PCI drivers menu in the kernel config.

Sound just works. Remember that ALSA defaults to all the volume levels being turned down at first, so you’ll need to turn the sound up for noise to come out of the machine. The best feature of the Intel AC97 sound chipset is that finally I can control the headphone volume separately from the speaker volume. That’s very handy, as I hardly ever use the speaker.

Unfortunately, the ThinkPad displays the same behaviour as my old X21 — plugging in the headphones disabled the speakers, and the headphone volume control seems to be ignored.

There is no line out jack, but I never use that anyway.


The wired network card is a an Intel Pro 1000 gigabit card. Use the e1000 driver, and all is good. I haven’t got the wireless network card working yet, as I’ve only owned the machine for a day… I’ll let you know when I have more to say on that point.

Update: There is a driver for the wireless card called “madwifi”… It just works.


I don’t use it, so I don’t know.


2 USB 2.0, Firewire, 2 PCMICA slots, S Video, parallel port (that one surprised me), external VGA, and docking station hole.


I’ve only used this to install the system, so I don’t know if it works well yet. I’ll get back to you on that one.

Other stuff

Well, I can’t think of anything else about the machine to mention, apart from the fact that the machine ships with a nipple (which I’ve always prefered, and is the normal ThinkPad thing to do), but it’s bigger and rubbery. It’s actually a lot nicer to use. It also comes with a touchpad like the Apple and Dell machines. I hate these, but I know other people like them, so it’s worth mentioning. I must also say that the keyboard is very nice, much better than the Toshiba, Acer, and Dell keyboards I’ve used recently. It’s also very close to full size because there is a lot of space for a keyboard for once. Very nice to type on.

The battery is huge (it protrudes out the back of the machine), and the machine is a little heavy at 3.147 kilos. It doesn’t fit in my old laptop bag, but IBM gave me a new one in their wisdom. I don’t know about my backpack yet.

Update: ACPI S3 hybernation (suspend to RAM) now works for me, even in X Windows! (23 July 2004)

So, after a very satisfying session with Len Brown from Intel at OLS, S3 suspension of the machine now works. What did I need to do to make it happen? Well, I used the latest 2.6 kernel bitkeeper snapshot (which will become 2.6.9, which isn’t out yet), and applied this patch, which will make it into the mainline kernel sometime soon, and then just compiled.

Everything just worked then if I do a:

    echo 3 > /proc/acpi/sleep

…and wakeup works by default. All you need then is a script in /etc/acpi/ to do the echoing when you shut the lid. I used these dodgy scripts:




My employer had a stand at CeBIT Sydney, so a car full of us developer types went up to have a sticky beak. It wasn’t really what I was expecting — the only other similar thing I had been to was MacWorld about 10 years ago — but was quite worthwhile. It’s amazing the amount of wireless hardware out there that people are pushing. It felt like about a quarter of the vendors there were selling wireless hardware of some form. I didn’t count the stands, but the telecomms area of the show was huge.

There were a lot of Windows machines there too. The only obvious Linux vendor I could find was a little booth in one of the corners. It was good though, it’s the first time I’ve seen Lindows / Linspire in the flesh. It’s a pretty blatant clone of Windows if you ask me.

My travel for OLS has been approved. Now to book some flights.