Toothbrush depilation, or, as it is known to its practitioners, “toothbrush depilation”, is a vibrant and exciting competitive sport. Although it has been around for the last two hundred years or so, it only came to the public notice when Hammurabi’s daughter, Hammuribena, was viciously murdered in Babylon. The ensuing civil war has guaranteed toothbrush depilation’s place in the homes and hearts of Australia’s most-beloved families.

Perhaps surprisingly, the sport has remained relatively unchanged from its Babylonian days, notwithstanding the French revolutionaries’ attempts to “simplify” and “democratise” it. Two teams attempt to remove the bristles from between five and six toothbrushes. Judges award points based on the number of bristles removed, their angular displacement, and the size of the bribe. Many have called for toothbrush depilation to be played at the Olympics, but unfortunately they had the wrong number, and so their calls could not be connected.

In Australia, the sport has had something of a checkered history. Forced underground by Hughes, it later experienced an upsurge in popularity under Menzies and Howard. Its detractors claim that it constitutes cruel and unusual punishment; its pundits counter this by pointing out that the detractors are all wimps.

With growing numbers of young Australians choosing toothbrush depilation over other, perhaps more conventional sports, it looks set to sweep the world in the new millenium. A bright future of bristles, bribes, and bloody murders beckons!

Autobiography

2011-08-31 – 6:53pm

I was asked today to write a short autobiography to go on the company website. This is what I wrote:

Barry van Oudtshoorn hails from the snow-clad plains of the Serengeti delta. Overcoming his debilitating muteness (Barry was born without a larynx), he has become an accomplished ventriloquist and master orator. He has presided over Presidential coming-of-age ceremonies and the marriages of seventeen Catholic priests, both in Uzbekistan and abroad.

The winner of the inaugural bi-annual toothbrush-depilation contest in 2010 (and a runner up the year before that), Barry leads a quiet life. Despite being married to Ariel, he has led a comfortable and well-cooked life. Barry enjoys making jellies wobble and cutting his toenails.

I’m not sure that this will be what goes up, though…

(Un)quoted HTML attributes

2011-08-07 – 4:23pm

In HTML, it’s perfectly valid to write something like this:

<p class=alpha>Lorem ipsum dolor sit amet etc.</p>

Indeed, Internet Explorer 7 and 8 favour this approach. Whereas Firefox, for example, would return the above as

<p class="alpha">Lorem ipsum dolor sit amet etc.</p>

when retrieving it using innerHTML, IE 7 & 8 only quotes attributes that satisfy certain criteria:

  • Any attributes that contain spaces;
  • Some magic set of standard attributes, such as href;
  • Any custom attributes you may have specified.

Unfortunately, however, this doesn’t constitute well-formed XML. In the software I develop at work, we produce PDFs that can include user-generated HTML. To do this, we use XSL:FO — an XML-based system. You can see where this is going: the backend requires valid XML, but the frontend is sending through HTML. The simplest way to fix this is with a simple regex, like so:

var s = '<p class=alpha>Lorem ipsum dolor sit amet etc.</p>';
s = s.replace(/=([^"'`>\s]+)/g, '="$1"');
// s === '<p class="alpha">Lorem ipsum dolor sit amet etc.</p>'

Bear in mind that this regex is by no means perfect. It will, for example, convert this:

<p class=alpha>Lorem ipsum</p>
<p>dolor sit=amet</p>

into this:

<p class="alpha">Lorem ipsum</p>
<p>dolor sit="amet</p">.

…which is obviously not what we want. I spent a while trying to come up with a regex that would solve this problem, but I stopped pretty soon. What’s really needed here is a parser: something that can take in the tag soup that Internet Explorer produces, and produce valid XHTML (which is valid XML). A quick search reveals myriad implementations in various languages — Python, Java, even JavaScript.

So, after all that, what’s the take-away from this post? Just this: web browsers (slightly older versions of Internet Explorer in particular) are imperfect. XML was borne out of HTML, and is much less forgiving; whether or not its strictness is a good thing is up for debate. I guess that it’s a bit like reading Shakespeare nowadays: you can pretty much understand it, but every now and then you have to reach for a dictionary to make sense of what’s going on. Of course, when you don’t understand something in Shakespeare, you don’t fall over in a heap, but let’s not stretch the analogy too far.

In brief

When retrieving the innerHTML of an element (or using contenteditable), Internet Explorer doesn’t always wrap attribute values in quotes. The solution to this is not a magnificently obtuse regex, but a tag-soup parser that can return valid XML.

Juggernaut

2011-07-11 – 7:01pm

A piece in the same vein as Fluorescent. My wife describes this piece as “dystopian”. I, of course, had to reply with this rather witty riposte: “Dystopia? I ’ardly even know ’er!”.

This piece is somewhat heavier than some of my other recent endeavours, but hopefully not too much so. In terms of VSTis, it makes use of the usual culprits: Reaktor, Massive, FM8, and Kontakt.

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

(Download)

Creative Commons License
Juggernaut by Barry van Oudtshoorn is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.