Posts from September 2007.

The drink of the gods

Chai latte is the nicest drink ever. That is all.

Well, not quite all. I have just discovered that Twinings make chai tea bags.

Twinings Chai tea bags

If you buy one of those milk frother things that look like a sex toy then you can make yourself a chai latte for the princely cost of about 5p (really), which is rather cheaper than the three quid I got stung for in Cafe Nero earlier.

vibrating love device or milk frother, you be the judge

hasAccount

Satisfaction, some new web service or other, has a neat wrinkle; on the sign-up page, you can specify your ID in one of a number of other services (flickr, technorati, last.fm, twitter, others) and it’ll retrieve your (publically available) information from there so you don’t have to fill it all in again. A good idea, I think. (It’s all done through the Magic Of Microformats.)

Something that would make it more useful, though, is if it highlighted which services it thinks you’re a member of. It’d be possible to do that if these online services provided a way to say “does the current user have an account here?” Imagine that Flickr, say, made available a URL http://flickr.com/services/hasAccount. When you call it as http://flickr.com/services/hasAccount?callback=myFunction, it looks to see if you, the user requesting the URL, are logged into Flickr. If you are, it returns this JavaScript:

myFunction(1);

otherwise (i.e., you don’t have a Flickr account, or you do and you’re not logged into it, or possibly you do and you are logged into it and you’ve ticked “hide my online status from other websites” in the Flickr account page) it returns

myFunction(0);

This would usefully let the Satisfaction signup page (and other services that want to offer the same sort of function) display which services it thinks you’re a member of: so for me, it would leave Upcoming and Flickr in the list and disable or grey-out or otherwise de-emphasise Cork’d and Twitter because I don’t have accounts there. This would be relatively trivial to do: Flickr just write somewhere “our hasAccount URL is http://flickr.com/services/hasAccount?callback=” and your code just calls that URL (by creating a <script> element with it in the src) and drops a callback-function name on the end of it so it can read the results. A nice usability enhancement, and it doesn’t particularly invade privacy (it’s a slight violation that site A can know that you’ve got an account at site B, but not a major one since they don’t get any details, and you allow people to opt-out if they choose).

For extra ease-of-use bonuses, although a quantum leap of privacy violation above that, have a hasAccount URL return

myFunction({”username”:”sil”});

instead, and then use hCard as above to automatically fetch the public information from that site. Obviously this is a lot less appealing from the point of view of keeping your information secret, though.

Apart from that it requires all the services to bother doing this, any reason why it shouldn’t happen?

DOMContentLoaded for IE, Safari, everything, without document.write

We have now had, for a while, a way of emulating the “DOMContentLoaded” event across all the main browsers. For those of you who don’t know what I’m talking about, a web browser fires an event, “load”, when a page finishes loading, and JavaScript can attach code to that event which will then run once the page has loaded. However, if there are big images or other slow-loading things in the page then the code gets delayed until after they’ve finished loading too; this is annoying, because most DOM scripting doesn’t actually need the images to be loaded, and so the delay is unnecessary. Opera and Mozilla fire a “DOMContentLoaded” event which runs after the page has loaded but before all the slow images and applets and Flash movies need to load, which is perfect. IE and Safari don’t fire such an event, but it’s been possible to do IE and Safari-specific things to make it happen. (In Safari you check document.readyState, in IE you document.write a <script> element with defer set. See Dean’s writeup.) If you’re using a JavaScript library of some sort (jQuery, Prototype, Mootools, whatever) then all this complexity gets wrapped up for you and you don’t have to worry about it, but if you’re writing stand-alone scripts (like my sorttable), which don’t depend on a library, then this is more of a problem; you have to include a big swathe of boilerplate code to emulate the DOMContentLoaded event.

Recently, Hedger Wang provided an alternative approach for IE that doesn’t rely on document.write, which is rather neat. So, it should be possible to combine the existing Safari method, Opera and Mozilla’s DOMContentLoaded support, and Hedger’s IE approach into a short bit of boilerplate code that can be dropped into your standalone script. And indeed it is. See a simple demo, and more importantly, here is the short version of the code:

(function(i) {var u =navigator.userAgent;var e=/*@cc_on!@*/false; var st =
setTimeout;if(/webkit/i.test(u)){st(function(){var dr=document.readyState;
if(dr=="loaded"||dr=="complete"){i()}else{st(arguments.callee,10);}},10);}
else if((/mozilla/i.test(u)&&!/(compati)/.test(u)) || (/opera/i.test(u))){
document.addEventListener("DOMContentLoaded",i,false); } else if(e){     (
function(){var t=document.createElement('doc:rdy');try{t.doScroll('left');
i();t=null;}catch(e){st(arguments.callee,0);}})();}else{window.onload=i;}})(init);

The init on the last line is the name of your “init” function; the one that you want to call on page load. (It could be an inline function if required.) Simply copy those 7 lines into your standalone script and change the name of the init function to be your init, and you’re good to go on all browsers. Remember that if you’re already using a JavaScript library then you don’t need this, but if you’re not then it’s simpler than the current swathes of code, and less heavy than depending on a library just to get access to cross-browser onload event handling.

DRM-free MP3 downloads from Amazon

Two years after I first laid out my plea to be able to download music the way I wanted, Amazon have pretty much come through. My canonical test song whenever someone announces a new music service is “Feelin’ Good” by Nina Simone, and here it is on Amazon.com. So, let’s test this service against my list of requirements.

  • I can download one track, instead of a whole album; I don’t want ten Nina Simone songs, I just want the one I’m looking for – PASS
  • No DRM. None. I don’t mind what the format is, if there’s no DRM, as long as it can be played on Linux (which is pretty much everything). Bonus points for oggs. Half a bonus point for just plain mp3. – PASS
  • A track costs a pound or less. I’m not paying more than a quid for one song. – PASS (99c is about 50p)
  • I feel comfortable putting my credit card number into the site. This means, in practice, that if it’s called something like mp3downloads.haxx0r.ru, I am not interested. – PASS
  • I can just buy a song by putting my credit card number in and getting it for download. I don’t need to sign up for an account, give them all my details, none of that. – FAIL
  • My music tastes aren’t very eclectic, so I’d expect the service to carry most of what I’d want to listen to. This means that a service for one label alone isn’t really what I want. I don’t want to discover new music with this; I want to get the stuff I already know about and want to listen to. – PASS
  • I’ll get, probably, about five songs a year. So a subscription service is out, especially since with most of them your music stops working when you unsubscribe. – PASS

So it only fails on one thing: you need to sign up for an account. However, I already have an Amazon account. This is still technically a failure — because my desire for no signup was not only for my own benefit but because I didn’t want it to be a powerplay by some firm who would then spam everyone who bought mp3s until the end of time — but largely people already have Amazon accounts and Amazon have shown themselves (in my experience) to be reasonable citizens in this regard. I don’t receive lots of spam or unsolicited “recommendations” from them, and (from a web, if not open source perspective) I think the Amazon Web Services are a Good Thing. So although that’s a fail I’m prepared to let it slide.

Well done Amazon, I say. I suspect that it’s only tracks from some record companies, or some labels, or some other criterion that I don’t care about, but since my test track appears there they must have at least some of the music I like. Now I get to start buying mp3s.

Update: dammit, it requires a US billing address. Obviously I could lie about that, but if I was happy to lie then I’d just google for the mp3. So it’s presumably US-only at this point. Anyone got any contacts at Amazon who could give me an indication as to when or whether it’s being rolled out to other countries?

Gnome filepicker windows

From the Ars Technica review of Gnome 2.20:

GNOME’s file dialogs are still extremely weak in many respects. For instance, the file dialogs still do not support even basic file management tasks like renaming and deletion. The file dialogs also lack adequate support for thumbnail display. Dialogs in some applications will show a thumbnail for one item at a time, but the file dialog windows do not display thumbnails next to individual files in the list—a feature that can be found in both KDE and Windows. It’s a serious deficiency that has long detracted from the general usefulness of GNOME’s file dialogs. In many cases, when I use a file dialog in GNOME, I find myself opening up a Nautilus browser and navigating to the same path so that I can see thumbnails or perform file maintenance tasks before saving or loading.

A long time ago, there was a patch for Gtk produced by the ROX team that added a draggable icon to the Gtk filepicker window — to save your document, just drag that icon to a Nautilus window. Those of you who remember RISC OS might remember that that’s the way you saved files there:

Saving a file by dragging an icon

There are a few UI problems with filepickers, as mpt pointed out a while back, and the drag-icon-to-save model neatly avoids them. There are, of course, issues: the main one is that in order to properly implement drag-and-drop saving, apps should use the freedesktop X Direct Save protocol, which I think means that every app must be patched to allow its saving to be accessed as a stream (so you can “save” a file directly into another application). I might be wrong about that being hard, though — my C-fu is not strong, which is pretty high on the list of reasons why I’m not trying to make this happen already.

The Tango project’s Window Experiments mockups have the draggable icon living in the top corner of the window itself, which seems like a great idea to me.

Is anyone working on this? I’d love to see whether it works out in practice.

Alternative DOMContentLoaded for IE

Interesting new JavaScript trick from Hedger Wang: poll the doScroll() method of an unattached DOM element until it stops throwing errors, and when it does, the DOM’s loaded. This gives you the equivalent of the DOMContentLoaded event for IE, and in a rather nicer way than the current-best method of document.write-ing a script tag with a defer attribute. I like this a lot, although I’d like to see some more detail about whether it works in all IEs before switching to it!

LugRadio returns for season 5

After a long-ish break over the summer, LugRadio returns for season 5! With an all-new pretty website, interview with Miguel de Icaza about Moonlight, the Linux implementation of Silverlight, and lots of the usual stuff. We’re planning to shake things up a bit this season; people have been asking us to come and do live shows around the country, and you can now get in touch to ask us about that. Let us know what you want to hear by mailing show@lugradio.org or going to lugradio.org/contact. If you’re in the USA (or can get there), then LugRadio Live USA is also now definitely confirmed! We’ll see you Easter weekend in San Francisco. Go get the first episode of Season 5 to find out more!

CouchDb

I’ve been poking around with CouchDb, like all the cool kids. It’s pretty clever; a database which isn’t relational, where the connection API is REST, and where queries are written in JavaScript and data is returned as JSON. It’s been accused of using all these technologies for reasons of cool rather than because they’re actually a good idea, but Damien Katz, one of the main authors, says that he uses JSON because “XML FUCKING SUCKS“, and ne’er a truer word was spoken. As Assaf Arkin says, “Relational databases have failed the software industry in much the same way XML, Java and client-server failed the software industry. In other words, no failure to see here, move along. Those are all excellent technologies for solving a wide range of problems. Just that there are some problems they’re particularly poor at solving.” It’s a neat and clever way of trying to solve some of those things that an RDBMS may not be good at, and I’m dying out to use it for something (but I’ve got too much on to invent yet another project). If you read about it and want to check it out, be warned that right at the moment all this cool JSON stuff lives only in svn — the last released version used XML and some kind of brain-damaged noddy SQL-but-not-really query language. Fortunately, they’ve seen the light on that in all possible ways. Sam Ruby has build instructions for CouchDb if you want to check out the goodness.

Tracking bugs for sorttable

I get lots of people mailing me for help with things I’ve written, and sorttable is way up at the top of the list. People find it useful, which is good, and they mail me to say thanks. I like that. On the other hand, they also mail me to say that there are a few things it doesn’t do. Now, they’re right; there are a couple of bugs that slipped through, and more importantly there are a couple of things that never crossed my mind until people started asking whether sorttable could handle them — loading tables with Ajax, tables with zebra stripes, that sort of thing. I’m now at the stage where in my “sorttable unprocessed” folder I’ve got over 150 emails, and an awful lot of them are about the same things.

So, a bug tracker seemed like a good idea. However, I don’t want one where everyone can submit bugs into it. I get little enough time to hack on projects as it is, without having to triage bugs as well. So, I wanted something which was basically read-only; a place where I could point people to say “look, here, the problem you have identified is a known issue, and I am planning on fixing it, and you can subscribe to this and get notified when I do fix it”.

So: the sorttable bug tracker.

It’s shamelessly borrowed from the PuTTY wishlist in almost all particulars, right down to the differing levels of priority. Simon Tatham actually pointed me, when I asked, at the code they use to run that wishlist. I had a couple of extra wrinkles I wanted to add, though, and their code is in Perl and I’m not much cop at Perl, so I built my own very similar thing. You can read my spec for a read-only bug tracker if you like; essentially, the bugs themselves are in a (secured) folder in my Subversion repository as RFC822-style files, and then there’s a little collection of scripts which know how to build a static HTML collection of bugs for the project. I’d like to make the scripts available so other people can do the same thing, but they’ve got passwords hardcoded into them (because the bug area in svn is secured, because there are bugs in projects that I can’t make public). If I can think of a way of making the code available, I’ll do it, but it’s relatively trivial anyway.

At the moment I’m only tracking sorttable bugs in here, but I’m gradually going to bring all my other projects that are me-develop-you-use things into it. It’s not suitable for something like Jackfield, which will eventually develop more of a community around it (and will therefore be a lot more collaborative); sorttable isn’t a big enough deal to be a community-maintained project, but I do need somewhere I can point people at when they say “why doesn’t it handle Ajax-created tables?”, and now I have that somewhere.

Which video card should I buy?

Dear Lazyweb: I’ve got a desktop machine, which I use sometimes at home. It’s plugged into a flatscreen monitor. The machine has an old Trident CyberBlade video card in it, which won’t drive the flatscreen at anything higher than 1024×768, which is pretty annoying. So, I’d like to buy a new video card for it. However, I’m horribly confused by video card stuff. Which card should I buy? It needs to be supported by free software drivers (i.e., not require the nvidia or fglrx binary drivers), but it does not need to do anything very exciting; I don’t play games on the machine, for example. It’d be nice to have the 3D compiz stuff, too. As far as I know, Intel don’t sell separate cards, which leaves me with ATI or nVidia; I keep hearing that “older” ATI Radeon cards are well supported by free software drivers, but I don’t know whether that includes enough 3D support for compiz, and I don’t know precisely what “older” means: ATI’s product range confuses the hell out of me. I’ve got no problem buying something from eBay, so it doesn’t have to be a card that is currently on sale in shops. Any advice gratefully accepted.

Snap

This picture from Flickr just got chosen as my desktop background by Webilder:

A picture of someone who looks like me on Flickr

I had to look two or three times to confirm that it wasn’t a picture of me. In the end it was the presence of the Mac that gave it away. It’s disturbing seeing yourself looking back out of your desktop.

Jackfield and Python talk

My slides from my Jackfield and Python talk at Pycon UK are available.

A few people have started hassling me to provide packages for Jackfield, my port of Apple’s Dashboard to Linux, so people can more easily try it out. What do you think, gentle reader? I’ve got very little time to work on Jackfield at the moment, and I felt that a better use of my time would be to try and make it run more Dashboard widgets, rather than to make the installation process easier — my thought was that the ease-of-installation process is critically important, but it’s critically important to users, and Jackfield isn’t meant to have users yet because it’s not close enough to being ready. Tell me what you think: should there be Debian packages, Ubuntu packages, Fedora RPMs? The point was made that there’s a lack of contributions from other people precisely because it’s too hard to install, and I found that a relatively compelling argument. So, let me know what you think in the comments.

All busy on the Western front

Stone me I’m busy. Bah. Haven’t even had time to write some things up here. However, my collection of kept-unread things in Google Reader has reached high enough proportions that I have to do something about it, so this gets a few things off my list.

A post about the stuff I discussed at LugRadio Live — whether it might be reasonable to make “be permissive about IP” be the default for Linux distributions and make the Americans and others in oppressive IP regimes do the legwork to remove what they consider to be “patent-infringing”, rather than all of us non-Americans suffering for it — is stacked into the holding pattern and circulating over Heathrow, incidentally.

Recent interesting things

Google Reader finally lets you search past posts
Thank god for that. Finally. Finally.
ATI open graphics specs and open source the driver for video cards
This is a pretty big deal, this one. At first blush it looks as if two of the three leading graphics card manufacturers (ATI and Intel)* will now have good support in open source. I imagine someone at nVidia has at least noticed that this has happened. More openness of this sort cannot be a bad thing. Well done ATI, I say.
I should note a couple of small reservations: it’s only for their newer cards (i.e., not most of the ATI cards that are out there), and it’s not as simple as them just open sourcing their existing fglrx binary driver. They’re providing a library to access the BIOS on the card, but most importantly they’re providing specifications for the cards. It’s still down to the open source community to write the driver itself, but we’ve historically not had a problem with that (and ATI are funding the initial writing of this driver!). Phoronix has more detail on what ATI are actually doing — the important quotation is “The aim of this open-source driver is not to overtake the fglrx driver but rather is designed for those who just want a working desktop with 3D capabilities and basic video playback. This new driver is ideal for FOSS enthusiasts” — the point here is that if you want the very best performance from your ATI card you’ll still need to go proprietary, but there’s now enough information that the open source code will be able to provide the things that a lot of people are clamouring for — 3d acceleration, video acceleration, 3d desktop effects. Well done, ATI, I say. Obviously I’d like to see it all being Free, but I’m confident in the open source community’s ability to build a great driver (maybe even a better driver than the binary one?) based on having the information they’ve asked for, and now they’ve got it. Blizzard’s thoughts are informative.
@media Ajax 2007
I’m really looking forward to speaking at @media Ajax this year. The list of speakers is pretty cool, indeed, including some people I’ve never had the chance to meet. As usual, details of events I’m going to be at are on my events page.
Separated at birth
John “jQuery” Resig says that he’s “baffled” by why I referred to him as John “Kelly Osbourne” Resig in an earlier post. Well, the camera doesn’t lie.

John Resig and Kelly Osbourne

On the other hand, John did an excellent Google Tech Talk on building a JavaScript library, so don’t hold it against him.

Convert a physical Linux box into a VMWare virtual machine
Useful, although convoluted. Parallels lets Mac people virtualise from a bootable partition, so you can either boot into your image or run it as a VM inside another OS. Can we do that under Linux? It’d save my dad rebooting into Windows to make his scanner work.