This is as days pass by, by Stuart Langridge

What if Google crashed

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. :)

Cutting down on spam (part XXXVII)

It occurs to me that I very rarely get useful comments on older posts, but I do occasionally (so just turning off comments isn't the answer). On the other hand, I don't want to put any road blocks in the way of most commenters. So what I decided to do was add a little bit of extra spam-avoidance to older posts. The Math [s] Comment Spam Protection plugin for Wordpress is ideal for this, but it adds the question (a simple one, like "Add 3 and 4") to every post. I didn't want that, so a tiny bit of hacking. After installing the plugin into WP, I edited my comments.php file in my theme and added this below the existing comment entry boxes:
<?php

# For old posts, display math-comment-spam-protection's "add these
# numbers" question.

if (function_exists('math_comment_spam_protection')) {
    $mcsp_info = math_comment_spam_protection();
  if ((date('U') - get_the_time('U')) > 2592000) { # 30 days ?>
<p><input type="text" name="mcspvalue" id="mcspvalue" value=""
size="22">
<label for="mcspvalue"><small>Spam protection for older posts: Add
together
<?php echo $mcsp_info['operand1'].' and '.$mcsp_info['operand2'].'' ?>
</small></label> <?php
  } else {
    # it's not an old comment, so write the answer ourselves!
    $vv = $mcsp_info['operand1']+$mcsp_info['operand2'];
    echo '<input type="hidden" name="mcspvalue" value="' . $vv . '">';
  } ?>
<input type="hidden" name="mcspinfo"
value="<?php echo $mcsp_info['result']; ?>" />
</p>
<?php
}
?>
Basically, what this does is work out whether a post is over 30 days old, and then if it is display the maths question. Since the plugin assumes it's on every post, it checks for the answer being correct on every post. So on posts that *aren't* more than 30 days old, we calculate the answer ourselves and fill it in! Seems to work so far. If I've got something wrong and it's stopping you commenting, please let me know through some non-commenty means :)

This is not the way the web works

(08:06:18) mitch21en@[elided].com: Hello (08:06:26) Stuart Langridge: hello (08:06:27) mitch21en@[elided].com: This is Mitch (08:06:34) mitch21en@[elided].com: I want to trade links with you (08:07:33) Stuart Langridge: I don't do link trading, I'm afraid. (08:07:48) mitch21en@[elided].com: What? (08:07:59) mitch21en@[elided].com: We are site realted (08:08:01) mitch21en@[elided].com: related (08:08:10) mitch21en@[elided].com: Here is my site (08:08:20) mitch21en@[elided].com: <a href=" http:// [elided] "> UK Garmin GPS, armin avionics, bose headsets, aviation GPS, aviation safety equipment (08:08:29) mitch21en@[elided].com: Your link will be hosted here: (08:08:38) mitch21en@[elided].com: http://[elided]/ (08:09:09) Stuart Langridge: I have nothing to do with garmins or GPS. (08:15:01) mitch21en@[elided].com: ok (08:15:05) mitch21en@[elided].com: Thanks for your tiem

Vodafone are liars. Film at 11.

I'm in the market for a new mobile phone. My SonyEricsson z800i (chosen after lots of helpful advice from my glorious readship) is now starting to feel the pinch a bit: the buttons sometimes don't respond, for example. It's also the size of Bolivia, which means that if I'm not wearing a jacket and I try and cram it into my pocket then I look like John Wayne. Plus, people laugh at me on the train because they think I'm doing a Gordon Gekko impression and it's some sort of performance art. So, new phone required. I do have a list of requirements, which you'll find below because I'm now looking for advice again, but I thought this time I had it cracked. After research (by which I obviously mean: reading things on the internet), I decided on the Motorola KRZR K1 (which is sometimes called a MOTOKRZR instead. why? Who the fuck knows. Perhaps they're twins.) It's a nice looking phone, and it did pretty much all the stuff I wanted it to do. Including (and this is important for the next bit), SyncML, the thing that lets you synchronise your list of contacts with a server out there on the wild wild internet. I need that: for one thing, I don't want to have to type all the people I know in again. For another, I like a backup. Thirdly, it means I can edit contact details on the web rather than on the phone. I already have a SyncML account at mobical.net, which is excellent; I don't want to move to another one. (People thinking "just store your contacts on the SIM card": that fails the "have a backup" criterion.) I noticed that Vodafone (my current mobile provider) offer the KRZR in their list of "phones you can upgrade to", and after a phone call it turned out that I could upgrade to that phone for free. How cool is that, eh? That sounds like the way for me. Yes, says I; I'll have that, please. Vodafone person: "It comes in two colours, sir, blue and silver. Which would you like?" Your gentle narrator: "What's the difference between them?" V: "Nothing; one's blue and one's silver." Me: "OK, I'll have a blue one, please. I like blue." V: "Certainly, sir, it'll be with you tomorrow by courier." The next day (Friday 16th March, last Friday) my brand new phone arrives. I excitedly unpack the box, put the battery and the microSD card and my SIM card in it, plug it in to charge up. Two hours pass, and it's completely charged. Ringing my phone number rings the phone -- yay! So, excitement building, I think: OK, time to pull down my contacts onto this phone. I RTFM (rly!) -- the Vodafone-branded manual, note -- to discover that the way you set up a SyncML connection is: Menu > Connectivity > Synchronisation > Vodafone sync > New Entry. Ah, but...in Synchronisation, there's no Vodafone sync entry. There's just Exchange, and that's it. After a few minutes poking around, I ring 191 to talk to Vodafone about it. After explaining my problem, and then explaining it again in shorter words, and then explaining it again to a technical person, and then explaining that I was following the instructions in their manual with their logo on the front, I get: V: "Ah, the blue KRZR doesn't have that function. You need the silver one for that." Me: (splutter) "But I spoke to your colleague who said that they were the same!" V: "I'm sorry, she must have got that wrong. The silver one supports SyncML and the blue one doesn't." Me: "But the phone itself supports it. You mean that you've deliberately disabled the function in the blue KRZRs?" V: "Yep." Me: "The silver one definitely does it?" V: "Definitely." Me: "OK. You'll send me a silver one and pick up this blue one at your expense, since you lied to me about them being the same." V: (concilatory tone) "Of course, sir, no problem. It'll be there Monday. At some point between 8.30 and 6pm." A little divergence here. How the fuck is it reasonable to say "We'll deliver it at some point in this NINE HOUR WINDOW"??? It was fortunate I could have this delivered to work. Everyone does this now. I end up having to take a whole damned day off when we have furniture delivered, and 90% of that time off is wasted for the half an hour that they actually deliver the bastard. While I appreciate that it's a different situation, Andy tells me that a drayman, delivering beer to pubs, can give you a FIVE MINUTE window in which they'll turn up, and they always manage it. Moving furniture is a bit different to moving beer, especially since beer deliveries are always to the same pubs rather than arbitrary houses, but it's just one more example of companies making customers bear all the brunt and pain even though they're paying the money. Fuckers. Back to the story. You can see where this is leading, can't you? Monday passes: no phone. Today, Tuesday: the new phone arrives. A silver KRZR K1. Unpack, put in SIM, put in microSD, put in battery, charge, two hours, turn on, ring to confirm it works, decide to check SyncML. (are you ready? prepare yourselves...you might want to hold on to something so you can properly handle the shock) Lo and behold, my snazzy new silver KRZR, which definitely, definitely supports SyncML, has exactly the same damned Exchange item and nothing else in its Synchronisation menu! Amazing, eh? fume, fume, fume, fume. 191. Wait for two minutes. Me: (five minutes of introductory stuff elided) "You swore blind that this phone wasn't hobbled like the blue one! grnch grnch grnch" (time passes. I try to not get too irate because it's not the fault of the call centre employee) V: I've spoken to our technical people, and they say that the phone supports SyncML." Me: "I know it supports SyncML! You numpties have deliberately turned it off in the Vodafone firmware! Which you swore blind you hadn't done on the silver one! grnch grnch grnch" V: "You'll have to talk to our 14-day returns department." (time passes. You may be eaten by a grue. Alternatively you may lose so much blood by bleeding out of your ears in anger that you fall unconscious.) Different Vodafone person: "No, sir, the blue and the silver phones are exactly the same, they're just different colours." Me: "But, but, but, I specifically asked that and was told it was not the case! I've wasted nearly a week of my life on this!" V: "All we can recommend is that you send the phone back. We'll cancel your 18 month contract extension when we get the phone back." Me: "And I shall go and talk to a third -party phone vendor who doesn't hobble their phones. Why do you do that, by the way?" V: "I don't know, sir." So, the phone goes back tomorrow. Remember, kids: winners don't buy phones from Vodafone, because they'll tell you lies about their capabilities. Their network seems fine, and their technical people seem fine if you can get to them, but their phone sales people just lie to you. Now I need a phone. I'm still debating the KRZR, but from a third-party. If you have any other suggestions that will meet the stuff below, I'm interested in hearing them.
  • A flip phone. Not a clamshell one (which is short and rounded and quite thick), but a long thin one (like the KRZR, or the z800i)
  • Not made by Sony. I'm boycotting Sony for putting a rootkit on people's machines and lying about it. Not interested in discussion on this point: I'm not asking you to boycott them, but I am doing.
  • Supports SyncML
  • Bluetooth
  • Enough Java support to run Opera Mini
For extra credit (read: I'd really like these things, but they aren't ultra-critical)
  • Supports JSR-75, which means that Java applets can read and write to the phone's storage (SD card). This will be immeasurably helpful for ReadManiac, the e-book reader that I use.
  • Charges over USB instead of a proprietary connector
  • Can be plugged into a USB socket and appear as a hard drive
  • Plays mp3s. For über-extra-credit: plays Ogg Vorbis.
  • I can buy it with a Vodafone contract, so I don't have weeks of pain transferring my number and getting a data account set up. If I can't, then it can be on any network except T-Mobile, who have ruinously high data charges.
Suggestions welcome. Remember: Vodafone tell you lies about phones. Watch out for them.

iTheora and Java support detection

Interesting project: iTheora, a PHP script handling in-browser display of Ogg Theora video files, using the Flumotion Cortado Java applet. The site's originally in French but has also been translated into English by Bruno (nice one Bruno!). I'd like to do this client-side with JavaScript. The big issue I find with Cortado, and indeed all Java applets, is: Java takes so long to start up. What I'd like to do is only load the Java applet if someone asks to see the video, and not show it at all if they don't have Java installed. The problem is: how do you detect whether the punter can display Java applets, without starting Java? As far as I can tell, it isn't possible. I've seen a few attempts at it, but none of them work across browsers. JavaScript people: how do you detect Java support without starting Java? I'm quite happy to write the script to do it if I can work out how, but all my experimentation and research have not led me to a solution. Lazyweb: help me out!

DED|Chain

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're so early into release. There are now sufficient libraries out there that one useful part of a new library's documentation would be to show "translations" between one of the "headline" libraries (YUI, Prototype, JQuery, Dojo...what else should be in this list?) and your new library; it'll help people who are already using libraries to understand why they might want to switch to yours, and it won't hurt people who are approaching your library as their first. So, a few examples which say "to do this effect, you'd do this in YUI, and you'd do it this way in MyNewLib" would not go amiss for new JS library developers; what you're trying to do with that is convince someone like, oh, say, me to move from their current library of choice to your new one. The advantage there is that people will go out and evangelise for you. Of course, getting someone who doesn't use a library at all to be convinced by yours is equally a coup; you can't dodge the need for proper documentation by just saying "read Prototype's docs and then convert your code from Prototype to MyNewLib" :) I was faintly surprised that D|C is an actual new library rather than just a "port" of the JQuery API to YUI (meaning that I could switch my JQuery apps to D|C without changing any code, and get the (debatable) benefit of the "reliability of Yahoo! UI"), but I guess that YUI's asserted reliability isn't enough on its own to motivate a port, and that'd stop Dustin doing anything innovative. Library proliferation is, in theory at least, a bad thing, but I don't think so. We're so early in doing structured JS development in a web-wide, collaborative way (not just inside one company, say) that it's worth exploring lots of different approaches to library development and JS development as a whole, and see in a year or so what's emerged as the leading techniques. Right, now I must go away and have a play with DED|Chain. Stupid name. I can't get out of my head the image of a chained and dead pirate, swinging from the gibbet in eternal torment. An idea for a logo there perhaps, Dustin.

Works on my machine

It Works On My Machine. A new certification program for software. Fantastic. I've immediately certified all my software under this brand new concept. Works on my machine (logo) (via Ned. Logo is Creative Commons Attribution-ShareAlike 3.0 according to Jon Galloway, the designer, in comments. Any of my team reading this: don't be tempted. It's nearly performance review time, you know.)

Time for some comic relief

Happy Red Nose Day from the LugRadio team! Remember, you can still donate to The Big Red Recording, a whole album in a day being done by LugRadio's own John O'Bacon.

No highlighting in searchhi

A chap mailed me to say: is it possible to have your searchhi JavaScript library, which automatically highlights things that the user searched for if they came to your page from Google or similar, not highlight some bits of the page like the navigation section? Good idea, I thought. So the library has now been updated to allow you to do precisely that: stop highlighting bits if they've got a class of nosearchhi. Thanks to Helmut Lorenz for the idea!

The web giveth, and the web taketh away

The WHAT-WG have been putting together specifications for a new version of HTML, to avoid the stagnation of the W3C. (Recently, the W3C seem to be responding to that by setting up their own working group, and you can be a part of that process; the WHAT-WG is already open to the public). Lots of interesting things happening there, but two recently show the two sides of the web, good and bad. First, you can embed video into Internet Explorer without using <object> or <embed>, using HTML+TIME, a really interesting open W3C standard that no-one else ever bothered to implement (like VML, really). Cool technique, and another example of how the Microsoft IE team do interesting stuff and don't just try and screw up the web. We have to remember this when preaching the new standards orthodoxy. And then, over on the dark side, Apple are asserting patent rights over the <canvas> element, which they invented and the WHAT-WG have included in their proposal for a new HTML. Microsoft doing cool exciting and innovative stuff; Apple using bully-boy legal tactics to shut down innovation. Funny how the wheel turns, isn't it?

Shortest way to create an XMLHttpRequest object

This should work in everything, I think, to get an XMLHttpRequest object for JavaScript in your browser: http = window.XMLHttpRequest ? new window.XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("MSXML2.XMLHTTP"): null); Of course, this only applies if you're not using a library to make all this stuff go away, which you maybe should be. But if you're not, this is a very short way to get the thing you need for Ajax.

Ahhhhhh

Steve and the gang are at South by Southwest and I'm not. However, they bought a beer and kept my place free anyway. What a bunch of heroes. Nice one. Sorry I can't be there with you.

RIP Chris Lightfoot

Bloody hell. Chris Lightfoot of MySociety has died. Rest in peace, Chris. You did some great work.

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