Archive for the 'Web' Category

Auditions

Saturday, April 26th, 2008

Lots of posts stacked up over Heathrow at the moment, like one about LugRadio Live USA, but for now I just have one bit of news. This morning, Niamh, my daughter, went to an audition to join the Stagecoach Talent Agency, and she was hugely successful. So successful, in fact, that they’re already putting her forward for an audition for a part on CBeebies, the children’s TV channel in the UK.

It is possible that I may burst with pride.

Fifteen years from now when she wins the Best Actress Oscar, I can look back and say “this is where it started”. CeCe Bloom, eat your heart out.

So proud. They said she was excellent.

gDay

Tuesday, April 1st, 2008

Q: Wait a second. I live in the US. Does this mean I’m now 2 days behind Australia?
A: Yes. Yes it does.

the gDay MATE future-search-engine announcement

I don’t normally like April Fools’ stuff on the web, but I’ll make an exception for this one :)

Hackergotchi

Monday, March 31st, 2008

Would someone better with the Gimp than me like to do me a hackergotchi for Planet Gnome? I’ve been meaning to do it for ages and not got around to it. This snap at Flickr seems like a good candidate, but go wild if you can think of a better one (CC-derivs-licenced Flickr pics of me as a starting point :))

Overriding a single field in the Django admin, using newforms-admin

Friday, March 28th, 2008

Django has been gradually changing the way their automatically-created admin system works to use the newforms-admin code, which makes lots of cool new things possible. However, because newforms-admin is rather new (ha!), it’s not brilliantly documented. One of the things I wanted to do today was to make one field use a custom field-editing widget that I’d created, rather than Django’s default textbox, in the Django admin system. You do that like this.

In newforms-admin, you specify admin options for a model by creating an extra ModelAdmin class for it:

class Vehicle(models.Model):
  colour = models.CharField()
  name = models.CharField()

class VehicleAdmin(admin.ModelAdmin):
  search_fields = ["name", "colour"]

admin.site.register(Vehicle, VehicleAdmin)

Imagine that we wanted to build a custom widget to allow people to choose a colour by clicking on a colour swatch. To do this, you need to actually create your custom widget. So, in a file custom_widgets.py, you create your widget. The easiest way to do this is to subclass one of the existing widgets (TextInput is a good one here, because that’s a normal textbox, which is what gets used by default for CharFields) and then change its render method:

import django.newforms as forms
from string import Template
from django.utils.safestring import mark_safe

class ColourChooserWidget(forms.TextInput):
  def render(self, name, value, attrs=None):
    tpl = Template(u"""<h1>There would be a colour widget here, for value $colour</h1>""")
    return mark_safe(tpl.substitute(colour=value))

There are a few interesting wrinkles in there.

First, overriding render() changes the HTML that your widget prints when asked to display itself by the admin system. (I haven’t actually implemented the widget there; left as an exercise for the reader, that bit.)

Second, you need to call mark_safe() on the HTML you return, otherwise the admin will escape it.

Third, all input to mark_safe() must be Unicode, hence the u""" at the beginning of the string. The parameter value already is Unicode, but any strings you provide must also be explicitly Unicode strings; otherwise, mark_safe() fails silently — the string will be escaped.

Fourth, you don’t have to use string.Template, but it’s pretty convenient.

Once you’ve created your custom widget, you have to hook it up to your model. In our example, we need to change VehicleAdmin:

from custom_widgets import ColourChooserWidget

...

class VehicleAdmin(admin.ModelAdmin):
  search_fields = ["name", "colour"]
  def formfield_for_dbfield(self, db_field, **kwargs):
    if db_field.name == ‘colour’:
      kwargs['widget'] = ColourChooserWidget
    return super(ArticleOptions,self).formfield_for_dbfield(db_field,**kwargs)

The formfield_for_dbfield() function gets called for each of the fields in your model; for the one we care about (colour in this example), override widget in the kwargs and then carry on with the rest of the function, and that hooks it up.

That should be it; now, in the Django admin system, your colour field will use your ColourChooserWidget for editing.

Aaron Bockover’s Gong-a-Thong Lightbulb Talk Extravaganza

Friday, March 28th, 2008

The one, the only, Aaron Bockover points out how great LugRadio Live USA will be when it happens in just over two weeks. Modestly, though, he refrains from mentioning possibly the greatest part of it.

Yes, this year, Aaron himself will be taking the prestigious role of orchestrating the Gong-a-Thong, a blizzard of incredibly short four-minute talks. Last year at LRL UK this went down really well — it’s a perfect opportunity for people who don’t normally get the chance to speak to stand up and talk for a few minutes about what they’ve been doing. (Incidentally, if you’re coming to LRL USA and you want to spend a few minutes wowing people with stuff, or mentioning your latest project, or ranting and waving your fists in the air about software patents or the bash shell or something, we want you to come and do it — contact us and let us know.

Those of you who were at LRL UK, or have seen pictures, will now be grinning at the thought. You see, it’s called the Gong-a-Thong for a reason, and the reason is that the signal for the end of your talk is someone banging a big gong when time is up. And the person doing it, much like the guy at the beginning of the old Rank films, is all oiled up with a thong on. Jono’s got a bit more history on how he and I thought up the gong-a-thong, and he’s right about the sense of pride we felt last year. This year, Aaron has stepped forward to be the man with the beater and the shiny gold underwear. It’s gonna rock like Alcatraz.

Bockonegger

Internet Explorer 8 standards-compliant by default

Tuesday, March 4th, 2008

Dean Hachamovitch on the IEBlog:

We’ve decided that IE8 will, by default, interpret web content in the most standards compliant way it can. This decision is a change from what we’ve posted previously.

This is really good news. The previous decision that IE8 would be IE7 unless you specifically told it to be IE8 was one that I was really quite unhappy with; it ignited discussion all over the web developer world. The reason that this is really good news isn’t because IE8 will be IE8 by default (although that’s exactly what was wanted): it’s really good news because this is an example (the first example?) of Microsoft being prepared to break backwards compatibility in order to do it right. It’s an example of trying to take people who are doing things wrong and help them to move into a world of doing it right, rather than bending over backwards to help those doing it wrong and punishing those doing it right. That’s been Microsoft policy up to now, and I’ve always felt it to be penny-wise and pound-foolish; it keeps everyone working, but inhibits progress. This is a fundamental change in policy, based on the new Microsoft interoperability promise. And that’s a brave move by Microsoft.

The IE team are to be congratulated, because making IE8 default to being as standards-compliant as possible is going to make the web better; it’ll be easier to build web sites and web applications that work across browsers, and those applications will be able to do more things. That’s bad for lock-in, but it’s good for the web as a whole, and that’s important.

Dean Hachamovitch again:

Shorter term, leading up not just to IE8’s release but broader IE8 adoption, this choice creates a clear call to action to site developers to make sure their web content works well in IE.

What we need to do that is beta releases of IE8 that can be installed alongside previous IE releases. Nobody who’s an IE user wants to replace their system browser with a beta, because betas break — that’s the point of betas — but we do all want to test with them. Allow IE8 to be installed in some form of “standalone” mode in an official, supported, way. The IE team have said in the past that the existing standalone mode is not supported, but if we could have a supported standalone mode then testing is much more likely to happen, and testing is what we need here. (Note: “create a whole new Windows installation in a virtual machine and test IE8 there” is not really what I’m talking about here.) Working with the WINE team to allow IE8 to run under Wine would be pretty helpful, too, especially given that this change in IE’s direction is being driven by a promise of interoperability.

This bodes well for IE passing the newly-released Acid 3 test, too. Hixie describes how the WebKit team are flying ahead on Acid3 support, just as they did with Acid 2; since Opera are pretty good at supporting recent standards, and the IE team are not only prepared to make serious standards-based decisions but have already committed to passing Acid 3, the Mozilla team might end up being last to pass, which would be a headline they don’t want.

In short: well done IE team. Now let’s see IE8 kick some arse.

DRM-free downloads in the UK, redux: hooray for Play.com

Sunday, February 17th, 2008

My ceaseless quest for DRM-free mp3 download files in the UK appears to be over!

A while back I tested Amazon’s mp3 store, which was fine except that you have to be in America. Fail. However, Play.com have just opened a similar store in the UK. As usual, my canonical test song for these things is Feelin’ Good by Nina Simone, and…I’ve just bought it from Play. As before, I have a list of requirements for these services:

  • 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

As with Amazon, Play fail on the “don’t need an account” idea. However, there are two extra thoughts concerning that:

  1. They let you re-download the track later (an indeterminate number of times, depending on the record company) if you lose it or delete it. This is a good feature, and I can’t think of a decent way of doing it without some sort of authorisation process.
  2. I have mailed them with a suggestion. If someone’s just buying downloads, why not have a “buy this without signing up” button, which just asks you for all the information that’s required on the “buy it” screen? (You can’t just enter a CC number; they need billing address and so on for the credit card companies, more’s the pity.) Then, quietly sign them up for an account under the covers, and when you send the “you have bought a download, go here to download it” email, say “oh, and we signed you up for an account, with password GF78F$0.Fsf;” and they can use it or not care. No idea whether the Play people will take this suggestion or not, though.

Anyway, it works. I can get songs and listen to them. Well done, Play. That will do nicely.

Fix embedded YouTube videos for Gnash users

Friday, February 15th, 2008

I use Gnash instead of Adobe Flash, because it’s open source, and because I largely don’t miss Flash. The one thing I would miss, though, is YouTube. However, Gnash (in Ubuntu gutsy), while it works fine at displaying videos on YouTube itself, doesn’t work on embedded videos (where someone puts the YouTube video on their own site). GreaseMonkey to the rescue; this very short GreaseMonkey user script simply replaces embedded YouTube videos with a big link to the appropriate YouTube page, so I can click through and watch the video. Only useful for people who are as lunatic as me about freedom but still like YouTube, which might be an audience of one.

Clicking it should allow you to install it, if you’ve got GreaseMonkey installed already in Firefox; Epiphany users with GM enabled should right-click the link and say Install User Script.

youtubepopout.user.js

generated-toc: Generate a Table of Contents with the DOM

Tuesday, February 12th, 2008

More excitement from the Stuart House Of JavaScript Stuff: generated-toc: Generate a Table of Contents with the DOM. A very easy way to get a table of contents onto your documents: generate a table of contents using JavaScript.

A big thanks goes out to the organisation who funded this work, who I can’t name. Getting stuff like this out into the world is a good thing, and them allowing me to open-source it is better still. Good work.

Firefox usage at 28%

Tuesday, January 29th, 2008

Blimey. According to Wired’s report on a “well-regarded as being accurate” XiTi survey, IE usage in Europe is at 66%, with Firefox second at 28%. Safari and Opera are both under a twentieth of the browsing population. Interesting stats, although all browser statistics are unreliable. I occasionally forget to stick my head out of the overheated greenhouse that is the web hacker community; looks like in the real world, Firefox is doing pretty well! Good work the FF team.

Reigniting the browser wars

Monday, December 17th, 2007

Alex Russell calls for a return to the browser wars, citing (among other things) the stagnancy of the W3C as a part of the problem, with the argument that browser makers are the ones who can innovate and they’re being prevented from doing so by a slavish insistence on “standards”. Meanwhile, Andy Clarke calls for the current W3C CSS Working Group to be immediately disbanded, Opera file an antitrust complaint against Microsoft, the HTML5 spec removes a recommendation for non-patent-encumbered video formats after pressure from Nokia and Apple, and all the old fights start up again. Fire and brimstone coming down from the skies. Rivers and seas boiling. Forty years of darkness. Earthquakes, volcanoes. The dead rising from the grave. Human sacrifice, dogs and cats living together. Mass hysteria.

Alex has a point. There is nothing but truth in the old saw that a camel is a horse designed by committee. Evolutionary theory tells us that actual forward progress happens faster in small communities, not in big ones. Browser manufacturer innovation is exemplified by Microsoft creating XMLHttpRequest, which ushered in the shiny world of Ajax; standards committee “innovation” is exemplified by XHTML 2.0, about which no-one gives a shit. Forward the innovation. Let the browser builders off the leash of blind and feverish compliance with “standards” made up by committee.

However. Let us not forget that the problem with the browser wars wasn’t that it fragmented the world in lots of different directions. The problem with the browser wars was that it fragmented the world in lots of different directions that weren’t possible to eventually implement everywhere. Don’t think of the output of this “innovation” as XMLHttpRequest. Think of it as the IE filter property, which is, as described on that page, “not available on the Macintosh platform”. For those of you innocent of such things, this allows you, in Internet Explorer, to apply a visual effect to a bit of an HTML page, where that visual effect is actually implemented by DirectX, Microsoft’s graphics library. Good luck porting that to Safari if it takes off. Oh no, hang on, it’s “not available on the Macintosh platform”, even in Mac IE, is it? Not that Mac IE exists any more.

The point here is very much the same as the point behind objections to DRM technologies on music. When browser manufacturers are told “go ahead and innovate — we want to see progress”, it’s jolly difficult for them to not think “hey, I know, why don’t we take this opportunity to provide something that we can do and other browsers can’t? Then, when people start using it, we’ve locked all their users into our browser!” There are corporate executives the world over furiously masturbating themselves into unconsciousness at the very thought of that technique being open to them again. Perhaps you’ve bought a few products from their corporations in the past.

Standards bodies aren’t really there to think up ideas, although that’s what they seem to have evolved into. They’re there to say, now, hang on a second, if you do that then what about all the people with no working eyes / some other operating system / touchscreens / no money for patent licences. They’re there to make sure that the web, which is meant to be there for everyone, isn’t separated into the haves and the have-nots, where the have-nots is everyone who won’t or can’t jump on the latest bandwagon. This is precisely why Silverlight is trying to supplant the web: to divide us into haves and have-nots. It’s why Flash is trying to supplant the web: to divide us into haves and have-nots. It’s why XUL as an application-development language for web apps was doomed.

It’s possible that the people Alex is calling on to do “innovation” in the browser will put the best interests of the web first, and the best interests of their companies and their browsers second. It’s also possible that a duck will fly in the window right now, juggle some lemon pies, and then deliver IE8, but I don’t think that that’s very likely either. The current mess over the proposed <video> element is a perfect case in point here: Nokia and Apple have refused to contemplate using the suggested Ogg Theora video codec as a baseline format, because they fear submarine patents despite the Theora project’s assurances. OK, they may have a point. However, the HTML5 people have stated, after this pressure from Nokia and Apple, that “we need a codec that is known to not require per-unit or per-distributor licensing, that is compatible with the open source development model, that is of sufficient quality as to be usable, and that is not an additional submarine patent risk for large companies”. It is just not possible for such a codec to exist. So, what we, the ordinary web developers of the world, are left with is precisely the same cluster-fuck that we currently have when publishing video: it is still not possible for me to make a video and put it on the web with some assurance that everyone can actually see the fucking thing. How is browser vendors’ “innovation” going to help with this? If they were truly “innovative” then we’d see them trying to co-operate on issues like this, because how can it be bad for ordinary web users and web developers to make it easier to publish and watch video?

Standards organisations aren’t there to dictate what Microsoft and Apple and Mozilla and Opera are “allowed” to implement. They’re there to provide a voice for people who will otherwise be merrily buttfucked and then thrown over the side in the pursuit of “innovation”. Think Web Standards Project rather than W3C. Of course, the WaSP seems to have lost its way and its voice a bit recently; are they coming back? It’s easy to just say “no, no, no” to new ideas, but it’s equally easy to say, well, I’m alright, Jack, if you’re not coming along with us then you’ll just get left behind, regardless of whether you’re not coming along because you’re unable to. If you think that Apple were right to resist video formats, ask yourself if you’d have been happy if the HTML5 spec had suggested Windows Media format as the default. If you think that browser vendors should innovate, ask yourself how happy you’d be implementing DirectX on a Macintosh. Fix things, yeah. Put some innovation back in, yeah. Let’s, though, try to not throw out the baby along with the bathwater.

Negative numbers in the Google Chart API

Saturday, December 8th, 2007

Google’s new Chart API is a useful little thing that returns a PNG of a chart based on the URL you feed it, so you can create graphs like this:

a simple example line graph

by just specifying the <img> src attribute as http://chart.apis.google.com/chart?cht=lc&chs=200×125&chd=s:helloWorld&chxt=x,y&chxl=0:|0|10|20

However, as Marty Alchin rightfully complains about, it doesn’t handle negative numbers at all. Obviously Google, being the internet success story that it is, never has any numbers for anything that dip below zero, but not everyone’s so lucky. However, there are ways to handle negative numbers in the Google Chart API.

Sort of, anyway. This is a bodge. Hold your nose and dive in. I’m sure Google will forcibly inject clue into their charting engine at some point, but until then you can sorta-kinda get around the problem like this.

a simple line graph with negative numbers

For line graphs with negative numbers, you need to do two things. First, lie about the values on the y axis (so you display on the graph that the y axis goes between -10 and 10, in the above example, even though it actually goes between 0 and 20). You’ll obviously need to transform your numbers appropriately, so a data series [-10, -5, 0, 5, 10] should be fed to the graphing engine as [0, 5, 10, 15, 20]. The second thing to do is to draw a horizontal line at 0 on the y axis; if we had real negative number support then that’s where the x axis should be, and so the extra drawn line “stands in” for it. That’s easy enough to do, using the grid lines chg parameter; just make the grid only exist horizontally, and have the grid divide the graph into two 50% parts, with chg=0,50,1,0. The four parameters 0, 50, 1, 0 mean “don’t draw vertical grid lines (0)”, “draw a horizontal grid line every 50% of the y axis (50)”, and “make the line solid with no gaps (1,0)”.

It’s also possible for bar graphs, although it requires a small amount more ingenuity.

a bar graph with negative numbers

This graph has negatives, right? Well, how it’s done might be clearer if you see this graph:

a bar graph without negative numbers, with the parts 'below the line' coloured in

Yep, you just stack up the bars, and make the bottom bit of the stack be transparent (note that in the first graph we have chco=00000000,ff0000,0000ff, which specifies colours for each data series; the first item in there is 00000000, which is in format RRGGBBAA, meaning 0% red, 0% green, 0% blue, and 0% visible. Actually, it could have been ffffff00, or deaded00, or anything; all colours are the same when they have 0 opacity! The second graph is exactly the same, except now the transparent bars are shown in green so you can see how it’s done.

You’ll note that all these graphs still have the “real” x axis (the line at the bottom of the graph) still visible. This is because there’s no way to turn it off, which is unfortunate both for this fake-the-negatives approach and because you can’t do decent sparkline graphs if you have to display the axes.

Both of the tricks above are horrible fudges which only need to exist until the Google Chart people rediscover the minus sign on their keyboards, which I’m sure is already in their bugtracker somewhere. If it’s not, then here, Google, take some of these: - - - - - - - - - - - - - - - - - - - -. Hope you find them useful.

Capturing Caps Lock

Tuesday, December 4th, 2007

Another JavaScript usability tweak from Stuart’s House Of JavaScript Weirdness: alert users if they’ve got Caps Lock turned on when they’re entering passwords into your web applications.

Capturing Caps Lock

Just install the script and go!

The other nice thing about this is that it’s part of 24 ways, the thing Drew McLellan runs every Advent showcasing 24 cool web things. I’m pretty pleased to have been invited. Drew is pretty pleased that this year I didn’t promise him something and then renege :)

Showing source in Firefox

Wednesday, November 28th, 2007

Annoyed that Firefox pops up the source of a page in a separate window when you View Source? Annoyed that Epiphany shows the source of a page in Gedit? Help is at hand! Simply drag the following link to your bookmarklet bar:

Toggle source

Clicking it will replace the page you’re viewing with that page’s source, nicely syntax-highlighted, in the same browser tab. Clicking it again will go back to the page. That should keep Sean Middleditch happy and stop complaints about Epiphany using Gedit as an HTML viewer.

(Warning: I don’t know what happens if you do this on a page where you’ve just posted some data, like if you’ve just placed an Amazon order or something. Don’t do that.)

Wordpress through Subversion

Friday, November 23rd, 2007

I have to say, I’m liking Wordpress’s install-with-subversion documentation. This will make it a lot easier to upgrade…

(update, 11.05: well, theoretically…)

(update, 11.12: you have to remember to upgrade the database once you’ve installed)

In short, making your Wordpress installation be a Subversion checkout seems like a great idea to me. It works easily (the WP people have instructions on how to convert your existing WP installation into a checkout of Subversion), they’re careful about tagging each new release (so you can upgrade just when releases happen; you don’t have to track the unstable bleeding-edge of Wordpress), and when a new release happens, upgrading is as easy as svn switch http://svn.automattic.com/wordpress/tags/NEW_VERSION/ followed by visiting http://server/wordpress/wp-admin/upgrade.php, and upgrades don’t come much easier than that, if you’re a techie like me. Good work, Wordpress team.

@media Ajax 2007

Thursday, November 22nd, 2007

Finally returned from @media Ajax 2007, and I had a great time. I was a presenter, talking about How To Destroy The Web, which I thoroughly enjoyed doing. My slides are here:

(in-line presentation made with a bodged version of John Resig’s easy PDF sharing, but using libpoppler’s pdf2ppm because libpoppler can read my PDF and GhostScript can’t, for whatever reason. You can also get the presentation as a PDF or see it on SlideShare if you’re a freedom-hating Flash person.)

It was a great conference. Particular highlights for me were Derek Featherstone talking about accessibility (since I don’t know anything about it and I should do), being asked to be on the panel at the end (with Alex Russell (!) and Douglas Crockford (!!) and Brendan “inventor of JavaScript” Eich (!!!)), the coolness incarnate that is Firefox 3 and whizzy SVG stuff, having Chris Heilmann spend two days trying to convince me how nice London was even though it did nothing but piss rain solidly the whole time I was there, finally meeting John “Kelly Osbourne” Resig, and having a rather pregnant lady (who may have been this lady) tell me that my talk was so funny that she nearly gave birth during it. That’s not a compliment you hear every day, that one; I was pretty chuffed with that, I have to say. Thankyou!

The usual suspects have photos on Flickr (tag seems to be “atmediaajax”); the wifi didn’t work (but it never does, at any conference); we’re discussing what (if anything) to do with the WaSP’s DOM Scripting Task Force (set up after @media 2005: the question is, do we still need a “task force”? Hasn’t DOM scripting now become part of the toolkit? It does still need to be used properly, in moderation, and not be critical for it to be present, but the concept doesn’t need evangelising any more, I don’t think); I shall be back for @media 2008. Great work Patrick and your orange-shirted helpers. Cheers to a cool bunch of people: it was great to catch up with Jeremy again, and having a beer with Drew and Rachel and Chris and ppk and Bruce and Harry and Alex and oh, just everyone is a good way to spend an evening. Maybe even more than one evening.

Cruciforum v1.24

Sunday, November 11th, 2007

Some upgrades to Cruciforum, which fix things like character encoding (it now actually gives a damn about utf-8, which is better than it was before) and individual-post linkability. I’ve also fixed almost all the HTML validity problems, but not quite all of them, so the HTML’s still invalid. It’s still on the bug list to fix, that, although next might be OpenID. I’ve also clarified that it’s GPL.

Cruciforum v1.11

Saturday, October 20th, 2007

I’ve fixed various things in Cruciforum and released a 1.11 version. In particular, there’s now Akismet integration to prevent spam. You can tell Cruciforum about your Akismet API key and then it’ll check new posts. There’s also a handful of other bugs fixed (see the bug list for details).

Next step is OpenID integration. I’m pretty confused by where the current state of play of OpenID is, though; since cruciforum doesn’t have a database or maintain much state, it’d have to be what was originally called a “dumb” consumer. I don’t know whether you’re still allowed to be a dumb consumer, though, and I also don’t know which PHP OpenID library fits in best with Cruciforum’s (a) fairly minimal requirements and (b) single-file nature (which rules out the JanRain library, which is about forty files). The simple class at PHPClasses looks OK, but is it? Suggestions welcomed.

Cruciforum: crucially simple

Tuesday, October 16th, 2007

Cruciforum

Cruciforum is a really simple web-based forum, designed to make it easy to add somewhere for discussion to go on to your website or a project. A Cruciforum forum is lightweight, doesn’t require a database, and can be set up on your server in about two clicks of a mouse. It’s the easy way to give people somewhere to chat about your project without installing something heavy and complex like PHPBB; just put the cruciforum install file in an empty folder and go to it in your web browser, and that’s all you need to do. Whenever I see a small project’s website I find myself wishing there was somewhere I could talk to people about it, and that’s what this makes easy. Go get Cruciforum for all your discussion needs, assuming that your discussion needs aren’t all that complicated!

hasAccount

Friday, September 28th, 2007

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

Wednesday, September 26th, 2007

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

Tuesday, September 25th, 2007

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?

Alternative DOMContentLoaded for IE

Monday, September 24th, 2007

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!

CouchDb

Friday, September 14th, 2007

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

Friday, September 14th, 2007

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.

All busy on the Western front

Friday, September 7th, 2007

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.

Speaking at @media Ajax

Tuesday, August 21st, 2007

The @media people have just posted a schedule for @media Ajax, in November this year. In addition to seeing me talk about how to destroy the Web*, there’s a veritable smorgasbord* of other speakers, like Brendan “I invented JavaScript” Eich, Douglas “I really understand JavaScript in a way that no-one else does” Crockford, Peter-Paul “quirksmode” Koch, John “Kelly Osbourne” Resig, Alex “Dojo is cleverer than you are” Russell, and others. It should be a good bash. I’m told that ticket sales are nearly closed, so if you want to come to London to see all these great people you need to get in quick. Get stuck in.

Chat to me

Sunday, July 1st, 2007

My contact page now allows you to chat to me in real-time without having to sign up to an IM service or anything. Steve Chipman, AOL hacker, took a break from painting good pictures of everyone who crosses his path to post about AIM’s new Wimzi widget; if you’ve got an AIM account, you can just go to the Wimzi site and get a widget for your website that allows people to talk to you even without their own AIM account. (It does require JavaScript, mind.) Good work. At the moment I’m just using the stock widget, but I’d like to customise it so that it fits better into the look of the site. Nonetheless, this is a pretty cool thing, especially when you think that this doesn’t have to be used for chat; it’s basically a generic way of throwing data around between websites and networks and computers over a checked network without signup required and easily. On the other hand, that network’s controlled by AOL, which might be a problem. On the third hand, AIM pretty much ranks as the best thing that AOL have done, even if the Pidgin project did have to change their name away from Gaim because AOL’s lawyers complained. I imagine it works with iChat names too, since they’re just AIM under the covers; so, let people chat to you! Open up the flow of discourse. Good work, Steve and the gang.

Yahoo Hackday is over

Tuesday, June 19th, 2007

What a fun weekend.

I had a thoroughly enjoyable time at the Yahoo/BBC hack day this past weekend. Dave Neary says “lightning struck twice”, referring to how he was left out of the programme for the conference he was at. Pah. Lightning did actually strike twice; the building I was in was struck. By lightning. Twice.

Excuse me while I say that again. The building I was in was struck by lightning.

Now there’s a pretty unique experience. Although it’s hardly surprising since Alexandra Palace has a 40 metre metal mast on the roof which looks like the Eiffel Tower and probably weighs about ninety tons.

Rumours abound that Google’s new weather API is actually a writeable API. If it were, it’d probably look something like Simon’s Google Smite. To be honest, the bolt hit the building just as I and a couple of others were slagging off Microsoft Silverlight. Draw what conclusions you will.


The roof panels open after the lightning strike, allowing cool refreshing rain to land on everyone’s laptops

Aside from inadvertent electrical events, a lot, lot, lot else happened. There were many cool hacks done with the BBC and Yahoo APIs, seventy in total; I think my favourite was Fruitr, which identified pictures of fruit that you emailed it and then suggested mad recipes in which to use it. Other highlights:

  • Jeremy Keith, Nat Downe, and others actually working really hard for the entire weekend and coming up with Hackfight, Top Trumps where your scores are based on how many twitters you’ve done, how high your Technorati rating is, that sort of thing. So it’s a game where you can find out who’s the biggest gimp. Cool hack, mind. :-)
  • Me trying to make sense of Simon Willison’s Oxford Geeks code and build a Birmingham Geeks site around it in one hour. And then discovering that the git depended on all of Django just so he could use its template engine for one 10-line template file. Good one.
  • I am going to set up Birmingham Geeks, though, so if you’re in this area leave a comment or something and when I do it you can see how to get on there. This will finally give me an excuse to go and have a beer with Bruce Lawson, which I’ve been meaning to do for about six months.
  • Travelling down on the train with Matthew Somerville and finding out about all the cool stuff that MySociety are doing, including a wicked cool hack with the BBC Parliament videos that I’m really hoping to see happen.

  • The wi-fi being constantly shit for all of the first day, even before the whole building was zapped. Pretty coloured circles on the Cisco wi-fi access points, though. Has anyone ever done a conference where the wi-fi worked properly? (Yes, I know about the Pycon writeup.)
  • Having two people come up and ask me if I was me based on recognising my voice from LugRadio. Cool. LugRadio Live is in three weeks, remember, people!
  • Meeting up with some people I hadn’t seen for a while and meeting some for the first time
    Aral 'Flash hero' BalkanA chap from Hacker Voice Radio whose name I never caughtJacob 'Django' Kaplan-MossSimon Willison and Andy BuddDave Glass, new Yahoo recruitNorm
  • Getting hassle from Christian Heilmann again about moving to London and working for Yahoo. I’m not moving to London, dude. Open a Birmingham office! Embrace telecommuting! It is the 21st century! :-)
  • I got pretty pissed off with my laptop, mind, which is fine when sitting on my desk but, what with it being stuffed full of proprietary hardware (listen to this week’s LugRadio for more on that) doesn’t work very well on the wireless (having to reboot to make it re-detect it five or six times a day, grr), hibernate properly, or work with a projector without rebooting. I need a conference laptop which doesn’t have a load of undocumented Broadcom and ATI hardware in it and doesn’t weigh very much. I must try and find a very cheap second-hand one somewhere.


People hide their laptops from the rain with umbrellas inside. An unusual sort of sight.

It was great. I did think about putting some hacks together but, to be honest, I was enjoying chatting away and meeting back up with people so much that I didn’t really get around to much actual coding. Simon was kind enough to credit the London Geeks stuff he did to “The Oxford-Birmingham-Kansas alliance”, with me being the Birmingham third of that, but that’s about all. I do have a plan for making Jackfield support Yahoo widgets, mind. Oh, and I helped out a very small amount with Gerv Markham and Ewan Spence’s rocket launcher, which was entertaining in itself and provided more than one laugh on the day. My pics available of the weekend.

Good work, Yahoo and the BBC. I have no idea whether the weekend met any of the goals you had for it, but you’ve convinced five hundred people that (a) you’re good companies, (b) there are many APIs out there which need mashing up, (c) it is possible to live for two days on Twixes and nervous energy, and (d) the world needs more weekends like this. When’s the next one? Bring it on.

Ads and directories

Monday, June 11th, 2007

The most popular thing I’ve ever written is the JavaScript table sort library, sorttable. Recently, I got into a discussion with the LugRadio chaps about advertising on websites, and whether it’s a good idea or not. I’ve toyed in the past with the idea of adding adverts to this site; it somehow feels a little distasteful to me, but during the discussion it became apparent that I don’t actually have any reason to back that up; it’s pure prejudice. Somehow it feels less pure to do something if you make money from it: the phrase “filthy lucre” exists for a reason, and the love of money is the root of all evil. On the other hand, I do love money since it lets me buy cool things. So. To ad or not to ad?

On the other hand, I got an email from the Dynamic Drive people asking if they could feature sorttable in their directory of JavaScripts. Now, one of the things that the JavaScript community have discussed (and this came up in this past weekend’s JavaScript pub meet — pics available) is trying to get good, well-coded, modern scripting into these huge galleries of download-and-use plug-n-play scripts. The idea here (and not everyone agrees with me on this, I feel bound to say) is that we are never going to convince some people to actually give a damn about the quality of scripts that they use or write. They’re just going to think, “I want some effect, I googled for that effect, and here’s a script that does it, so I follow the instructions to drop that script into my site, job done.” Since that’s going to happen, we should make sure that the scripts that people find are decent ones. That’s why I wrote sorttable, for example: to ensure that people have a simple drop-in decently-coded way of doing client-side table sorting. One good way of doing this is to talk to the current big repositories of scripts, like Dynamic Drive, and work with them to try and make sure that their scripts are good ones.

But…if I put the script on Dynamic Drive, then some people will get it there instead of from me (even though there’ll be a link to my site) and…that’ll hurt my ad revenue, if I have ads.

So, questions therefore, for those of you out there reading this, whether you’re a JavaScripter or a website owner or just a consumer:

  1. Would it be a good idea or a bad idea to have ads on some of my pages? (I’d probably do the browser code and other code pages, and old (not current) weblog posts.)
  2. Should I put the script on Dynamic Drive?
  3. Should I do both?

Your opinions greatly received in the comment box.

Replacing Flash with something else

Tuesday, May 15th, 2007

Benjamin Otte writes about replacing Flash with SVG, HTML, and JavaScript. It’s possible — look at the OpenLaszlo LZPIX demo for the same app in Flash and HTML to see that it can be done — but there are a few things in the way. Flash has a number of advantages which would need to be replicated.

  1. Multimedia support. YouTube and the like have recently become the biggest Flash users in the world, I imagine, and what makes that possible is Flash’s support for video; similarly, there are lots of in-browser mp3 players (like XSPF) which use Flash because of its support for audio. Existing play-sound-from-JavaScript projects like SoundManager2 use Flash to actually play the sounds. The WHATWG-proposed <video> and <audio> elements will provide this in the browser eventually, assuming that they’re actually implemented and we can get around the issues of what video formats are supported (Apple are lobbying hard for video format support to not be mandated, meaning that the element will be broadly useless on the web itself — Safari will support QuickTime-supported videos, IE will support WMV, Firefox and Opera will support Ogg Theora). This is a big problem, but there are tentative steps toward solving it.
  2. Single-file deployment. Once you’ve made a Flash file it’s one file — whatever.swf. That’s highly easy to deploy. It will be possible to make single-file deployments of a scripting+SVG+HTML+images bundle, but it’s harder; images are a particular problem if you intend to support Internet Explorer.
  3. An IDE. This is what Otte calls for, above, noting that animations require coding in an HTML+SVG+JS environment and they don’t in Flash, and that “the best Free authoring tool is either vim or emacs”; not what he’s suggesting that we do use, but a wry comment on the lack of authoring tools for standards-compliant rich web apps. An IDE is fairly critical to get this sort of technology out to the masses.

Ignoring the elephant in the corner of multimedia support for the moment (but it’s a big elephant, and mustn’t be forgotten), everything else is pretty much doable. Creating an IDE would be possible; SVG is available most places now (and is emulable in IE, and there’s always the <canvas> element, which is also emulable in IE); single-file-deployment isn’t critical, really (instead of a complicated <object> tag to embed a Flash file, it’s <iframe src="mywidget/">, with your JS/HTML/SVG widget in a folder). It’d be supported everywhere, you wouldn’t have to worry about the direction being solely controlled by one vendor, and it uses technologies we already know rather than trying to supplant the open web as Microsoft’s Silverlight is doing. Those of you who doubt that HTML is capable of this sort of thing, take a look at Apple’s Dashboard widgets, which do many cool things and are pure HTML, JavaScript, and <canvas>.

You might even be able to convert existing Flash movies to it using flasm, which would get the project up and running pretty quickly.

Of course, the idea needs a name. It would be nice to have it not be named after toilet cleaner, like Flash or Ajax. Whoever writes the IDE gets to think of the catchy name and be immortalised for ever. If you need a name, call it “April”. No catchy acronym, it’s just a nice word, and it’s when my daughter was born.

Currently desperately trying to not start writing this.

This week’s guest publication

Wednesday, May 9th, 2007

Jeffrey Zeldman asks his readers which they’re more interested in, Adobe CS3 (presumably some designer thing?) or Windows Vista. In a similar vein, I’d like to ask readers of this site which you’re more interested in, Sun’s JavaFX or signing up for TissueWorld 2008, the Premiere Exhibition and Conference for the International Tissue Industry. Answers on a postcard.

Please, spare me the oh-so-amusing “I’m way more interested in bog roll than I am in Java” answers, if you would.

Nicetitles now handles image links

Tuesday, May 8th, 2007

My nicetitles JavaScript library now handles links with images in them. Countless people have mailed me about this over the last four years; finally Vigdor mailed me and chased me down on instant messenger and I decided to get off my lazy arse and fix it. It now works. There is clearly a lesson here for those of you who want me to do stuff.

Your Honey Pot Caught A Harvester!

Monday, May 7th, 2007

---------------------------- cut ----------------------------

Stuart –

Regardless of how the rest of your day goes, here’s something to be happy
about — today a honey pot you installed successfully identified a
previously unknown email harvester (IP: 61.183.167.138). The
harvester was caught by your honey pot installed at:

www.kryogenix.org

Don’t forget to tell your friends you made the Internet a little better
today. You can refer them to Project Honey Pot.

---------------------------- cut ----------------------------

Project Honeypot is a system designed to catch email spammers. Basically, you sign up for their site and they give you one PHP (or ASP, or Cold Fusion, or half a dozen other things) file. You drop it somewhere in your webspace and throw in a couple of links to it (hidden on your own pages). The idea here is that ordinary people don’t follow the links, but spammer screen-scraping robots do. On the page is an email address and what looks like a weblog comment form, randomly generated, but tied to your Project Honeypot account. If any email arrives at that email address, which is run by Project Honeypot, or comments are posted through the comment form, then they know it’s spam (because only robots will scrape the email address and then mail it). Whether it’s a large help in the great fight against spam or not I don’t know, but it’s pretty easy to set up and once it is set up you don’t have to do anything. And as you can see from above, I’ve already identified a spammer that they didn’t know about.

You can see my honey pot at http://www.kryogenix.org/random/hpot/pedatetightknit.php if you want to take a look. Just looking at it confers no penalty. The comment form on it is hidden with CSS by default, so it might not be visible when you look. Don’t mail any email addresses you find on the page, though!

Signing up for your own honeypot is pretty easy (although I wish they’d use OpenID for accounts); I’m supposed to refer you, but there’s no “affiliate accounts” or similar. Go get one, and we’ll all try and help.

New photo gallery at LiveJournal

Saturday, April 28th, 2007

For some time now, I’ve been trying to work out where best to store my photos. You see, I’d like a gallery on line, so people can view it, and I’d like to be able to do simple photo editing — rotations, reflections, red-eye removal, that sort of thing. I was therefore caught between the idea of a local photo program, on my computer, and publishing those photos to an online gallery, and the idea of just having the online gallery and making sure that it’s one that can handle the editing requirements I’ve got. For some time I went backwards and forwards on this, thinking one way way best and then the other. I even toyed with the idea of writing some sort of web-based photo management app. I don’t like keeping things in two places — it’s an invitation to them getting unsynchronised. On the other hand, most of the existing web-based photo management (as opposed to photo display, for which you need nothing more than HTML) apps are shit. So, between a rock and a hard place.

One night I had an epiphany, which is: bandwidth is not infinite. Doing all my photo management online is unacceptably slow and annoying in a world where one photo might be 2MB in size. I couldn’t bear it. Of course, here, I’d fallen foul of one of the Eight Fallacies of Distributed Computing. Much as people would like to claim it, remote resources and local resources are not equivalent, at least not until we get a decent fast internet. That being the case, I needed to plump for a photo management app on my machine and then simply publish the photos online. Now, the choice of photo management app was fairly obvious: F-Spot. It’s nice, it integrates with Gnome. Its main competitor on the Linux desktop is Digikam, which is pretty good but which I just don’t like. No particular reason, and no discredit to the digikam team; it’s just not my sort of thing.

One big download later and I’d imported all my existing gallery photos into F-Spot. It also made it easier to import new photos from my camera, which was nice. Next step, then: putting these photos on the web so people can see them. F-Spot supports exporting to a number of existing photo sites (Flickr, smugmug, etc), to Gallery, the PHP online photo gallery thing, and to its own HTML layout and jimmac’s Original gallery. I was all geared up to use the HTML layout, at which point I found that it can’t be customised. I want my gallery (eventually) to fit in with the look of my site. So, I thought to myself: I’ll write something that parses that HTML, grabs all the info out of it, and then creates my own static HTML gallery. That’s a good idea.

Two months pass and I’ve done fuck all. What this actually means, when this happens, is that I’ll never get round to it. After three decades I know my own mind, even if it takes steps to hide what it’s thinking from me occasionally. In the interim, something important happened: Jono posted a few images on his website, they got syndicated onto various planets, and as everyone pulled up the image it drove our poor server to its knees. After some experimentation with ImageShack for this sort of thing, we came to the conclusion that off-site image hosting is what we need.

So Jono went to Flickr, because he hates freedom.

Flickr’s pretty good, I’m not going to deny it, but, as has been related in these pages before, I’d like to try hard to use free software only where possible. I’ve got no problem with paying a subscription to someone who’s doing the hosting for me, but I’d like to use someone who’s got open source running their site. Flickr might use lots of free software under the covers, but it itself isn’t free. Other photo sites seem to be the same; Smugmug are very proud of how they use free software, and they contribute changes and extra code back to the community in a good way, but the software for the site itself isn’t Free, so I was loath to use it.

Those of you saying “I bet you use Google!”, yes, yes I do. I didn’t say I’d succeeded in every way in not using non-free software, but two wrongs don’t make a right; just because I’d given in in certain areas doesn’t mean I should give in in all areas, does it?

And then I had a brainwave. LiveJournal is built on free software, and it’s released and available. And they do photo hosting. After a bit of looking around, I established that yes, indeed, they do, the code is open source, and so off I went to LJ. And now I have my photo gallery online. Well done, Brad and LiveJournal. I said before, a long time ago, that if the Semantic Web works then it’ll work on LJ first; looks like running a public profitable service without hiding your source away is working first there too.

It needs theming to look like the rest of my site and just generally not look horrific. I am aware of this, but I haven’t had a chance yet to properly understand the LJ “S2″ theming engine. I’ll get to it. I am also aware that by not being on flickr I miss out on being part of that community; my photos won’t show up in tag searches, that sort of thing. That is a shame, and I am indeed missing out; still, there you go.

This also means that I have finally got photos of the 2007 SOCPA mass lone protest available. Enjoy the site of Bill, Ginny, and I holding up signs in front of Westminster landmarks! And if you think we look daft then, well, where were you when we were protesting, eh?

Jon Hicks’ beautiful Google Reader theme

Monday, April 16th, 2007

The great Jon Hicks has put together a beautiful theme for Google Reader. Makes it look so much nicer.

Simple installation instructions for Firefox. First, install the Stylish Firefox extension. Restart Firefox to make it work. Then go to Google Reader and click on the Stylish icon on your status bar, and choose Write Style > For this URL….

Download Jon’s gReader.zip file and open greader.css from the gReader/Firefox + Camino/ folder in it. Copy the text out of it and paste it into the big textbox in the Add Style window. Add a description (I called it “Jon’s Google Reader Stylator”, but do whatever you want). And: pow! Pretty Google Reader! Everyone’s a winner. Nice one, Jon.

WebKit browser on Linux

Sunday, April 8th, 2007

Update: the trivial WebKit browser is now included in Ubuntu. Simply install libwebkitgdk0d on Ubuntu gutsy (just click the package name there to install it if you’re running gutsy now) and then run /usr/lib/WebKit/GdkLauncher to get a simple WebKit browser for testing your code.

You too can test WebKit, Apple’s web rendering engine and the thing that makes Safari work, on Linux. The KDE teams have been working hard on making it work inside Qt, the KDE widget set, and indeed it does work! A few simple steps are required.

First, check out the WebKit source code. There is loads of it, so this will take a while. You’ll need Subversion for this.

svn checkout http://svn.webkit.org/repository/webkit/trunk WebKit

That will give you a folder called WebKit. You’ll now need a few requirements; the key one is Qt4. On Ubuntu 6.10 (edgy), get this like so:

sudo aptitude install libqt4-dev

Now build your Qt-based WebKit browser:

QTDIR=/usr/share/qt4/ WebKit/WebKitTools/Scripts/build-webkit

Finally, run it:

WebKit/WebKitBuild/Release/WebKitQt/QtLauncher/QtLauncher about:blank

I created a menu entry to run it (right-click on the Applications menu, say “Edit Menus”). Now I can test stuff in WebKit!

Note that the Subversion version of WebKit is miiiiiiiiles ahead of what Safari is using in released versions of Mac OS X, so don’t think that just because something works in your little WebKit browser it’ll work in Safari. Nonetheless, cool.

Sorttable v2: making your tables even more sortable

Saturday, April 7th, 2007

Sorttable, the JavaScript table sorting library, is pretty much the most popular thing I’ve ever written. (Top hit for “javascript sort table” on Google, too.) Over the four years or so since I first released it, there’s been a steady trickle of thanks, feature requests, and bug fixes to it. I’ve finally got around to releasing a new version of the script that hopefully covers everything that people were looking for. You can get it at the same place as it ever was, sorttable: Make all your tables sortable.

What’s changed in version 2

The most important thing that’s changed is that sorttable now has a much much clever automatic column typer. You still can just drop sorttable in place and not have to do any configuration, but it’s quite a bit cleverer about working out whether your columns are numeric or dates or currency or text. It skips blank lines, it can tell the difference between English and American format dates, it understands numbers with commas in and negative numbers. This is the number one feature request.

Secondly, you can now use custom sort keys for those columns that sorttable can’t work out for itself. See the page for details, but this should allow anyone to make anything work with sorttable v2.

It’s also a bit more compliant with HTML standards. To add a “totals” row you should add the row to a <tfoot> section in your table. Sorttable v1 used a class of “sortbottom” on totals rows; for backwards compatibility this is still supported, but you really should be using <tfoot> instead.

In a similar way, sorttable now uses <thead> as your column headers if you have it. If you do not have it then it will create a <thead> and put the first row of your table in it. This is a backwards incompatible change: to apply style to your table headers, you should now style table.sortable thead, not table.sortable a.sortheader as in v1.

Input elements are now supported in table cells! If your table cells contain input elements then sorttable will use the value in the input element.

Sorttable is now quite a lot faster than it used to be, owing to various little tweaks. It’s especially fast at resorting the table by the column you’ve already sorted by (but reversed), because now it just reverses the table rather than doing the sort.

Stable sorting is supported but commented out in the code (because the stable sort is implemented in JavaScript, not using the native list sorter, and so it’s a lot slower). You can change this by editing one line in sorttable.js if stable sorting is important; see the page for details.

Thanks

Lots of people (really, really lots) have contributed code suggestions, feature requests, bug reports, and compliments about sorttable. Here’s my chance to say thankyou. So: thankyou to…

Eric Chang, Mehmet Kut, Dan Synder, Jeff Bradley, Eric Holstege, Victor Kryukov, Nikola Ivanov, Geoff Clevenger, Mikko Suniala, Scott Reynen, Justin Meyer, Leonardo Kenji Shikida, Ben Ostrowsky, Daniel Berlin, Richard Snazell, Mark James, Eric Rizzo, Garve, Andreas Rehm, Scott Kingdon, Marcus Månsson, Bill Barry, Michael Rumpler, Avi Rogers, Kevin Wu, Espen Hovlands, Petronel Laviniu Malutan, John M. Pierre, opus27, Brendan Bowles, Marty O’Brien, Alex Rubin, Chris Gay, Jack Vanhan, Guy Rosen, John Dawson, Ryan Korczykowski, Carl Forde, Pete K, Glenn Haser, Richard Grassy, Olivier Briat, Bob Hanson, Alex Z, Narayana Rao Kankipati, Rey Hernandez, Eric Moriztz, Marco Valk, Marcus Daniel, David Dockhorn, Angela Weise, Aneel Nazareth, Jeremy Hulford, Thomas K. Weinstock, Edward, Matthew Egbers, Anton Berezin, Moustafa Elqabbany, Justin Williams, Daniel Chace, Inigo Surguy, Vladimir Kornea, John Mund, Pablo, David Golden, Brad Kemper, Brian Schott, Christian Robottom Reis, Justin Haygood, C. David Eagle, Simon Willison, and Dean Edwards.

Phew! All those people have contacted me asking for new features or have sent me patches or have provided code that I was able to reuse in v2 of sorttable. Thankyou: for those of you who wanted sorttable to do something new, I hope you like it.

What if Google crashed

Saturday, March 24th, 2007

GMail and Google are being slow at the moment, and it made me think: imagine if Google went down for a whole day? I mean, it’s unlikely, what with them having four million redundant data centres or whatever their disaster recovery provisions are, but how much would it knock their status as darling of the internet if you spent a whole day trying to get there and couldn’t?

The Yahoo people would do well out of it, that’s for sure.

That’s why they’ve got four million data centres, mind; they’re well aware of this.

Of course, it’s probably being slow at the moment because of my net connection. :)

DED|Chain

Tuesday, March 20th, 2007

Dustin Diaz releases DED|Chain, a JQuery-a-like library based on the Yahoo UI library. Apart from winning this week’s “Most Ridiculous Name For A Software Project” award (previous winners include Ning), it looks pretty cool. Nice work, Dustin.

There is one concern, though. When I say it’s JQuery-a-like, I’m not kidding; it looks a lot, lot like JQuery. This isn’t necessarily a bad thing; I use JQuery all the time because I think it’s brilliant. However, it’s pretty clear to me when I’m looking at arbitrary JS code whether it’s JQuery code or not. Now, with D|C in the world, I’ll have to be pretty careful to know which bits are DED|Chain bits and which are JQuery. In fact, I’m inclined to not use D|C too much purely because I don’t want to pollute the bit of my brain which remembers JQuery things with parts of D|C.

Of course, it’s difficult to know precisely what D|C supports because the link to the docs (http://dedchain.dustindiaz.com/api/docs/, as mentioned in readme.txt) is 404, but I’m assuming that that’s just because we