This is as days pass by, by Stuart Langridge

Upgraded to Wordpress 2.0

I've upgraded this site to Wordpress 2.0. This means, as usual, two things. The first is that I need to redo the theme, so I'm currently with the default. (Yes, I know themes are portable. Mine may not have been.) The second is that hopefully the problems that were causing this machine to be slow and die sometimes were related to hacks I'd made either in my theme or to Wordpress 1.5.2 itself, and this may resolve them. We can but hope.

My life in pictures

(22:09:12) Ted "Novell" Haeger: Bite me.
(22:15:49) Ted "Novell" Haeger logged out.

Hitting the Wayback Machine

I find myself hitting 404ed pages all the time, and wanting to look the pages up in the Wayback Machine to see what they said when they existed. So, a quick bookmarklet: Get archived version. Drag to your bookmarks bar and click when you hit a 404.

DTrace-ing JavaScript

Arr! Me hearties! I be highly impressed to see that prime landlubber Brendan Gregg be applying the power of DTrace t' JavaScript. For those o' ye scurvy dogs that dunno, DTrace be this marvellous thing on Solaris that traces kernel calls. Apparently it be for more than that, though; see Brandan trace the JavaScript code
function padZero(i)
{
        if (i < 10) return "0" + i
        return i
}

function startTime()
{
        var now = new Date
        var time = padZero(now.getHours()) + ":" +
            padZero(now.getMinutes()) + ":" +
            padZero(now.getSeconds());
        document.getElementById('clock').innerHTML = "time: " + time + "
" var timeout = setTimeout('startTime()', 1000) }
and be gettin' the followin' output:
 FILE                   FUNC                          CALLS
 clock.html             getElementById                    9
 clock.html             getHours                          9
 clock.html             getMinutes                        9
 clock.html             getSeconds                        9
 clock.html             setTimeout                        9
 clock.html             startTime                         9
 clock.html             padZero                          27
as well as much more complex output t' be seen below. Every day I be amazed at DTrace, and now I be even more amazed as it be useful for work that I actually do. Avast!

More spam

Today I got the following spam email:
From: info@[redacted].com
To: me
Subject: Important m$6h?3p

See the ghg5%&6gfz65!4Hf55d!46gfgf

 <Server Error #203>
Well, I'm now convinced to buy their product, whatever it is.

OperationalError: SQL logic error or missing database

If you're getting OperationalError: SQL logic error or missing database from your Python web script, first check that your SQLite database is readable and writeable by the user that Apache is running as (www-data if you're on Debian/Ubuntu) and that the folder that the DB file is in is also readable and writeable by the Apache user. Your webserver needs to be able to write to the file. That is all.

Online desktop

I wonder if you could build a Linux distro where the only program installed was Firefox? You make it look like an ordinary desktop, with "Word Processor", "Email Client", "Web Browser", etc, but the word processor is Writely and the email client is Gmail, both of which come up in their own chromeless window so they seem like a separate application, and the web browser is a stock Firefox window. You might not even need X for this. Obviously it'd be about as much use as a chocolate teapot without access to the net. File storage is online, and each "web app" you use has been hacked (with GreaseMonkey or similar) to save to your online repository; you get a "file manager" which is probably some Ajax thing to manipulate the files on the remote server and to open them in an appropriate application (where the URL of the remote file gets sent to the local host, which then opens one of its "applications" like Writely and passes it the URL of the file to open). Not sure how useful it'd be, but it'd be pretty small, and it'd genuinely prove that the web really can be your apps. What's missing from this picture? Assuming you're prepared to live with Flash (which I personally am not until Gnash comes along) then multimedia isn't really a problem. There's no web-based equivalent of, say, Jokosher, but there wasn't a web-based equivalent of MS Word either until fairly recently either. Your apps probably wouldn't be as good as desktop apps, because we're in an early stage of development of web applications, but that's only a matter of time, and maybe it's outweighed by the convenience of having your fully working desktop on a 16MB USB stick. (Look at how many people use webmail, despite its UI being worse than desktop mail apps; even if you think that new webmail clients like GMail or Yahoo Mail are as good, people still used Hotmail in their droves before the whole Web 2.0 thing.) One more project I probably don't have time to build...

Search Query Theatre

As per Aquarion, some of the more bizarre search queries that have brought people to kryogenix.org recently:
things to know when in prison
If you drop the soap in the shower, don't pick it up
does chicken make u fat ?
No. Believe me, I know. Pizzas make you fat. Not doing any running makes you fat. Chicken's really healthy. As are cigarettes.
when did the first molluscs appear on earth
Got some homework to do there, huh?
need to lose weight because penis is small
ahahahahahahahahaha. ahaha. ha ha ha. ahahaha.
neopet porn
Oh my God. My daughter looks at neopets.com. Christ almighty.
how to get a dieing cat to eat
For God's sake! Take it to the vet! Don't search the bleedin' internet!
is huh a word
huh?
because she's silently screaming, cant you hear her? listen carefully
wtf?
the cheapest thing you can buy from ikea
Any advance on a BÄSTIS hook for £1.49? See, this is why all websites need an API. I don't have time to screenscrape the site, so see if you can find something cheaper.
he started punching him in the face
Why? Why would you search for this? Why?

Tea-focused questions

should you put milk one with earl grey
No! No you shouldn't! No! Don't do it!
how to get someone to make a cup of tea
What you do is constantly piss and moan about it until they cave in. Well, that's what I do.
optimum infusion water temperature for a tea bag
Boiling! Boil the water! How hard can this be?
That's enough of that. I'm just getting annoyed now.

Extremely noddy TortoiseSVN for the Gnome desktop

I use the Nautilus Subversion scripts to manage my Subversion working copies all the time. The big thing that they're missing is TortoiseSVN's pretty icons that get displayed on each file so you can tell at a glance whether a file has been changed or not. Well, that sort of thing is also possible, because you can write Nautilus extensions in Python. Grab my svnemblem script and drop it in .nautilus/python-extensions in your home directory. You'll need to restart Nautilus to make this work (which basically means logging back out and in again) and you'll need the Python Subversion bindings (package python-subversion in Ubuntu: not pysvn, which is package python-svn) and the Python Nautilus bindings (Ubuntu: python-nautilus). You can test it's working by running TMPDIR=<some temporary directory, not /tmp> nautilus --no-desktop <path to an SVN working copy dir>. (thanks to Xalior for help with testing) Update: there is something of a problem, in that the emblems don't update if you change anything. This seems to be because once Nautilus has been into a folder once, it doesn't call the extension when you go in there a second or subsequent times, even if you hit Reload. I don't know whether this is fixable or not at the moment; I'll try and look into it. Any suggestions gratefully accepted!

LugRadio Season 4 begins

LugRadio is back from the summer break! The first episode of season 4 is now available at lugradio.org. Hear us talk about which projects got overlooked in the Summer of Code! Marvel as half the LugRadio team are now working as part of the Ubuntu team! Be amazed at how we're now in our fourth season! Mail the show!

Making .local DNS address lookups work on Ubuntu Dapper

I've got avahi installed on Ubuntu Dapper, so I assumed that that would make looking up foo.local address lookups work. Lots of sites say "add mdns to the hosts line in /etc/nsswitch.conf", but it wasn't working. What is needed is an "mdns plugin" for nsswitch.conf, which is nss-mdns. Installing this (it's the libnss-mdns package in Ubuntu) made it all work; I can now ping foo.local and it works! Yay! (not sure why it isn't there by default...)

Decoding Morse, the computer way

Jeremy Keith's been sent a Morse message and is wondering what it says. Well, I now know what it says, cos I wrote a program to decode it. First, I went and got the mp3 of the message from Odeo and loaded it into Audacity. (No, not Jokosher; I'm at work, and there's no Jokosher port for Windows. Audacity is still a free software audio editor, though, so being able to just download it is very handy indeed.) Audacity can read mp3s; I resampled it to 48000Hz (which made the peaks clearer) and made it mono (rather than stereo). At this point I could theoretically have decoded it by looking at the waveform: as you can see from this Audacity screenshot, that's clearly the Morse code .... .. .-.-.- (short sound is a dot, long sound is a dash; that decodes to "HI.") However, that'd be boring and laborious, and what if the message was five hours long, eh? You wouldn't want to transcribe that by hand. So, get the computer to do it! I didn't want to write an mp3 parser, though, and because I was on a Windows box I didn't have GStreamer available which would have helped with this. So, I exported the sound from Audacity as a WAV file, and then went off and got sox, the Swiss Army knife of audio converters and another open source program. Sox can convert a sound sample to its "data" format, which is a load of lines that look like this:
               0  -6.1035156e-005
  2.2675737e-005  -3.0517578e-005
  4.5351474e-005                0
  6.8027211e-005  -3.0517578e-005
  9.0702948e-005   3.0517578e-005
   0.00011337868  -3.0517578e-005
   0.00013605442                0
   0.00015873016  -3.0517578e-005
    0.0001814059  -3.0517578e-005
where each line represents one sound frame; the first number is "number of seconds since the beginning of the sample", and the second is "loudness of this frame". So, that's the answer! The loudness will be high where there was a sound and low where there wasn't. I needed to go through the data and find all the loud bits and all the quiet bits; a long quiet bit is a space, a long loud bit is a dash, and a short loud bit is a dot. No problem: quick bit of Python scripting:
fp = open("jezza4.dat")
data = [int(abs(float(x.split()[1])) > 0.01) for x in fp.readlines()[2:]]
fp.close()

# count all the runs
counts = []
current = -1
count = 0
for i in data:
  if i != current:
    counts.append((current,count))
    current = i
    count = 0
  count += 1

# now remove all short runs, which also removes the -1 row!
counts = [x for x in counts if x[1] >= 15]

# and reaggregate everything
counts2 = []
current = -1
count = 0
for i in counts:
  if i[0] != current:
    counts2.append((current,count))
    current = i[0]
    count = 0
  count += i[1]

mystr = ""
for x in counts2:
  if x[0] == 0:
    if x[1] > 350:
      mystr += " "
  elif x[0] == 1:
    if x[1] > 500:
      mystr += "-"
    else:
      mystr += "."
print mystr
and that printed out the Morse code for the message in dots and dashes! Nice and easy. Quick trip over to a Morse code converter to read it, and there we go. Message decoded. Good one, Tom. Oh, you want to know what it said? - --- ..- --. .... .-.. ..- -.-. -.- .-.-.- - .-. .- -. ... -.-. .-. .. -... . .. - -.-- --- ..- .-. ... . .-.. ..-. .-.-.- .-- . .-.. .-.. -.. --- -. . - --- -- .- -. - .... --- -. -.-- --..-- - .... --- ..- --. .... .-.-.-

Converter Deskbar

Another thing for Gnome Deskbar: a converter that converts one unit to another. Enter "23m in feet" and immediately get the answer that that distance is 75.46ft. Inspired by Google Calculator's similar behaviour, you can download the program and drop it into your ~/.gnome2/deskbar-applet/handlers folder. You'll need to have GNU Units installed as well (install the "units" package in Ubuntu). Some examples: Convert '$50000 in pounds', '4 lightseconds in furlongs', and '4 litres in teaspoons' Download Converter Deskbar now!

Another DHTML Utopia review

Nate Klaiber reviews DHTML Utopia and is rather nice about it. Thanks, Nate! Did I mention that you should buy my books?

JavaScript Libraries Friend or Foe podcast from @media 2006 published

I was a speaker on the JavaScript panel at the @media 2006 conference this year, and they've just published the audio from that JavaScript panel for everyone to listen to. Go thou and listen!

Are you ready for it?

LugRadio season 4: 11.9.06

Back from holidays

I am back! You may not have realised I was away. I have been in Caorle at the Villagio Hemingway with Sam and Niamh, and it was fantastic. Took quite a few pictures, too, which will be up soon. I love Italian food. I love speaking Italian. I love sun. I don't love that I go back to work tomorrow.

This website belongs to Stuart Langridge. Contact details are available. Don't eat yellow snow. Valid HTML5, at least in theory, except for the bits that aren't because I'm that futuristic that I'm ahead of the spec, oh yes. HTML5 help from Bruce Lawson, among others. Fonts from the superb FontSquirrel. End.