Wednesday 9 December 2009

All Self-Service Checkouts Are Not Equal

Having just read this article about The problem with self-service checkouts on the BBC News Magazine site, I started to pen a response but it soon grew beyond a simple comment, so I thought I'd publish it here instead.

Let's look at two stores differing approach to self-service.

Sainsbury's variant seems specifically designed to be as inconvenient as possible, with a tiny area allocated for you to tortuously scan all your shopping and then put-each-item-one-at-a-time-into-the-bagging-area. The system is a nightmare if you are trying to pay for a large grocery trip.

To date, I have never had an experience with Sainsbury's self-service where the system didn't have a problem of some description requiring a staff member to meander over and enter a code to allow me to continue. It always falls over if I try to use my own bags rather than taking fistfuls of the orange plastic ones provided. I was in there last weekend and the ghastly thing allowed me to finish scanning and bagging all my shopping before unceremoniously dumping me back to a booting screen, before the Windows XP boot progress screen appeared. At times, I have seen a staff member allocated to each self-service till, which somewhat defeats the point of the things, doesn't it?

It is also stupendously slow. Heaven forbid that you scan three of the same item in quick succession - the system will have a complete spaz on you. No, you must scan each item very deliberately, then place it on the weigh bridge in the bagging area so that the system can be sure that you haven't scanned a banana instead of the tumble dryer you are attempting to pilfer.

Conversely, Waitrose' QuickCheck system is a joy to use and a genuine time saver. It is equally at home on those occasions when you run in to grab a handful of items, or when you have a major shop to do.

Using a hand-held scanner you carry with you, you can bag your shopping as you take it from the shelves, so there is no ridiculous unpacking to do at the checkout. The scanner will even alert you to special offers related to items you have scanned and give you a running total of your bill, with any discounts precalculated. When you are done, you simply scan an 'end of shopping' barcode at the self service till and feed it your credit card. Waitrose' shoplifting protection consists of random 're-check' spot checks, where the contents of your bags are checked against the contents of your hand-held scanner. I've had three re-checks ever, and I've been using QuickCheck for years, so I do not begrudge them at all.

The fundamental difference between the two systems is that the Waitrose system is built on a basis of the store trusting its customers to scan their items correctly and pay the appropriate amount for their shopping, while Sainsbury's system treats its users as incompetent at best, and criminal at worst. The difference is striking, and leaves me clearly in favour of one approach over the other.

Monday 16 November 2009

Gotta Love Joined-Up Government

As many will know, five weeks ago today, back on October 12th I had an episode of impactful tarmac interaction - as in I came off my bike.

Of course, to say 'came off my bike' does not illuminate the context of the event, and lends itself to speculation of incompetent riding resulting in a self-inflicted tumble, or perhaps the other extreme of having been mowed down by an errant eighteen-wheeler.

In the interest of illustration, I shall provide that required context in the form of... telling you what happened.

I was pootling along Long Lane in Tilehurst, Reading (UK), which is near where I live. As I was approaching the junction with Orchard Close, I saw three boys (I'd say between 8-10 years old I think) on bicycles waiting on the pavement to cross the road. The first of them kicked off and was safely to the other side long before I was anywhere close. The second made a motion to go, but looked and saw me, and stopped. I made eye-contact to make sure he'd seen me, and he met my eyes. Confident he was staying put, I continued.

And then, just at the moment when a crash would have been unavoidable, he pulled away and into the road. His front wheel went into the forward part of mine, spinning it so that it was perpendicular to the rest of the bike - which naturally continued its forward momentum, up and over the handlebars, taking me with it.

I landed on the road on the heels of my hands and took a good knock to my left elbow before the bike landed on me and mangled me a bit more. The other guy was fine, in case you're wondering. I sat by the side of the road for a few minutes while I tried to recover my breath, then I tottered off in the direction of home.

Long story short, after a few hours of the pain not getting any better and a bit of a fainting episode, I was taken to the local hospital's Accident & Emergency department where I had a few X-rays and was dismissed a few hours later.

The next day I received a call from the consultant radiologist, who said that actually there might be some damage (a microfracture in the elbow) that would not have shown up in the early X-rays, and that I should make an appointment to come back after a few weeks if things had not improved. Four weeks later, (on my birthday no less) I was back at A&E to see why my wrists were still so painful. I could not turn keys, unscrew bottles, pick up Elliot etc. without massive pain, so I hoped to get something sorted out.

I was kitted out with splints for both wrists, in case of a possible scaphoid fracture and told to come back in two weeks for a follow up.

This is where we return to the title of this post.

I live on the other side of town from the hospital, and getting to it entails a journey through some of the busiest roads in Reading. Knowing how badly congested these routes can be, I requested a late-morning apppointment so that the traffic would be light.

I was then informed that this would not be possible. Not because there were no appointments to be had, but because some jobsworth at the Royal Berkshire NHS Foundation Trust has decreed that patients must be booked into the first available appointment on the required day, so that a contiguous block of appointments is constructed. I was therefore landed with a 9:05am slot, meaning that I would have no choice other than to drive through the very peak of the rush-hour traffic. No amount of explaining that this was ludicrous would persuade the old boot behind the desk to change the time.

And so, this morning, I set out from home at 8:15am in order to have a hope of reaching the hospital in time for the appointment. Sure enough, in short order I was sitting in gridlocked traffic going nowhere fast and a journey that should have taken fifteen minutes took over an hour. I jostled for space with rushing commuters, feeling completely out of place, as I make a point to never venture out onto the roads at that time of the morning, specifically to avoid the crush.

I finally signed in to A&E at 9:25am, twenty minutes late for my appointment. Of course, that made no difference to the time I was seen, as I have never been seen at the RBH fewer than forty-five minutes after my designated appointment time.

So let's look at the facts and figures:

Had I left at 10am for a 10:15am appointment, I would have spent only fifteen minutes in the car and would have occupied largely empty roads, arriving on time to my appointment.

On the other hand, having to cross town for a 9:05am appointment, I had to spend over an hour in the car, most of which time was spent at a stand still. My presence there contributed at least 4x the emmisions it would have done had I left at 10am, and that's before we factor in the additional emmissions from the other drivers around me who were slightly delayed by the fact that they had to share the road with my car too. I arrived late at A&E, potentially delaying the treatment of other patients and breaking their scheduling.

So that was a long blog post to simply get across the fact that I do not appreciate being forced to venture out into peak-time traffic because some government-paid fool doesn't know how to work a scheduler, while at the same time being directed from other wings of the government to avoid driving in rush-hour traffic unless absolutely unavoidable.

Who would have thought it would be a wing of the government that would make it unavoidable themselves. Pathetic.


I forgot to mention the reason that I had to go back to A&E at all.

On my first trip back to the hospital, I asked if I could be assessed by my local GP for the next appointment. I was told that this would not be possible. Upon inquiring as to why, I was told that my GP would not have access to the X-rays that had been taken. To me, this makes absolutely no sense whatsoever, as the doctor to whom I was talking at the time was looking at my X-rays in digital form on her computer. Has the NHS not got a network so that this kind of data can be shared? I hear there's this great invention that might just be of use to them... it's called the interweb, or something like that...

Thursday 23 July 2009

Thai Curry

This particular blog is for Onimua, who asked me over Twitter how easy this kind of dish is to create. You must excuse the quality of the photography in this entry - with the exception of the image above, I just took snapshots with my iPhone, the camera on which is pants.

The answer to Onimua's question is, 'very' - if you have the right ingredients.

To start, you will need:
  • Thai curry paste
  • Coconut milk
  • Creamed coconut
  • Palm sugar
  • Thai fish sauce
  • Bamboo shoots
  • Petits pois
For the particular variant I am describing here, you will also need:
  • Fresh galangal
  • Baby corn
... and your curry paste will need to be yellow.

There are five different kinds of Thai curry paste readily available in asian supermarkets and the occasional western supermarket. They are Red, Green, Yellow, Masman and Panang. Each have their own characteristics, between fiery hot (green) and gorgeously aromatic (masman). In this particualar instance, I'm using yellow curry paste.

The curry paste you use is bar none the most important ingredient in the curry. If you buy it in a pretty little glass pot with English text on it, it's going to be crap - trust me on this. What you need is a relatively large plastic tub containing a sealed bag of paste - the tub will have a label covered in Thai characters and may have a ropey English translation if you're lucky. That's the one to buy.

So, here's the basics.

Put a couple of large teaspoons of the paste into a glass bowl with some vegetable or groundnut oil. Mix it all together until you have a smooth consistency.

Shred some chicken and put it into the bowl, then mix it around until the meat is well covered with the paste-oil mix. Leave it for as long as you can. Overnight in the fridge is best, but five minutes is enough at a push.

When you are ready to cook, chop some bamboo shoots into thin strips (or buy a tin with them already stripped and then drain them). Peel and slice around an inch of galangal root into very thin strips, approximately a quarter of the thickness of the bamboo shoots.

Heat some oil in a wok until smoking, then put in the chicken that has been coated in the paste. When it's browned, add the galangal and bamboo shoots and continue to fry for a couple of minutes.

Set the wok aside and pour a tin of coconut milk into a large saucepan. Put this on a low heat on the stove, then transfer the contents of the wok into the saucepan. Add another couple of teaspoon-sized dollops of palm sugar and another couple of curry paste into the mix, stirring it into the coconut milk. Put a lid on the pan and allow it to simmer.

In the meantime, put a little more oil into the wok and quickly stir-fry some baby corn. After it is browned, pour in a handful of frozen petits pois and keep frying until they are heated through. Keep the corn and peas aside for the time being.

When you are ready to eat, add the corn and peas to the saucepan, along with a teaspoon or two of fish sauce and some creamed coconut.

Stir it all through and serve with steamed or coconut rice.

Wednesday 1 July 2009

Workaround for jQuery's lack of scope management in event / AJAX handlers

Yesterday, I wrote about the importance of the ability to have event callback functions reference this as the containing object of the method in which the event listener was created, and noted that with version 1.3.2, jQuery does not support this functionality.

I also found that the latest version of jQuery (straight from SVN) supports scope assignment through the .bind() function. This seemed great, until I realised that it's necessary to have similar functionality for AJAX handlers too, and jQuery still lacks this.

Therefore, after some fiddling around, the following workaround was devised:
scope: function(fn, scope)
return function()
return fn.apply(scope, arguments);
Which allows us to do the following...
myClass.prototype.addHandler = function(element)
$(element).click($.scope(this.handleClick, this));

myClass.prototype.handleClick = function()
// this refers to the myClass object, yay!
The very nice thing about this is that it can be used anywhere that jQuery offers a callback, simply by wrapping the callback function in $.scope(callback, this).

For now, problem solved.

Tuesday 30 June 2009

The Importance of 'this' Scope Management Through Javascript Event Handlers

During the development of vBulletin 3.x, much of our Javascript code started to take on a far more object-oriented style. With more widespread use of client-side scripting for features that would appear multiple times on a page, such as popup-menus vBMenu and collapsible elements vBCollapse, having encapsulated code made development much easier.

With one exception - event handling.

Let's take some very simple code to illustrate the problem. The purpose of this code is to force all links to be diverted through a different script. It's overkill, but it illustrates the problem.
function linkRedirect(link_element)
this.redirect_base = "";
this.link_element = link_element;
this.handleClick, false);

linkRedirect.prototype.handleClick = function(e)

// The following will not work
window.location = this.redirect_base
+ escape(this.link_element.getAttribute("href"));
In order to get around this, one can use a closure and refer to it instead of this in the event handler callback, like this:

function linkRedirect(link_element)
this.redirect_base = "";
this.link_element = link_element;

var closure = this;
this.link_element.addEventListener("click", function(e)
, false);

linkRedirect.prototype.execRedirect = function()
window.location = this.redirect_base
+ escape(this.link_element.getAttribute("href"));
Unfortunately, closures can be a great source of memory leaks, especially in Internet Explorer, and are best avoided if possible.

Mid-way through the development of vBulletin, we came across the Yahoo! User Interface (YUI) library, which wraps all this stuff into one beautiful function, which allows this to be passed as a parameter to the callback:
function linkRedirect(link_element)
this.redirect_base = "http://localhost/~kier/jq/redirect.php?url=";
this.link_element = link_element;

YAHOO.util.Event.on(this.link_element, "click",
this.execRedirect, this, true);


linkRedirect.prototype.execRedirect = function(e)
window.location = this.redirect_base
+ escape(this.link_element.getAttribute("href"));
Isn't that fantastic?

So why am I writing about this? Well, I've been playing with jQuery and found to my horror that it does not have this scope management system by default, requiring a revertion to the bad old days of closures and helper functions... ugh.

Today, I'm going to attempt to extend jQuery to be able to pass scope parameters in the same way that YUI does. Good luck me...

Sunday 28 June 2009

Garlic and Ginger Chicken Fried Rice

This is a recipe I've been making for a long time now. It's not traditional chinese in any way shape or form, nor does it claim to be. It's just easy to cook and delicious, take it or leave it.

Since Jo was diagnosed coeliac, I've had to make a few changes to the recipe, such as making hers with gluten-free ingredients, but essentially it's remained the same since I started cooking it many years ago, with minor tweaks here and there.

Firstly, let's have a list of ingredients.
  • Thai fragrant jasmine rice (or american long grain if you can't get jasmine - just not easy cook rice - that stuff is rancid!)
  • Fresh eggs
  • Chicken (or turkey) breasts
  • Frozen peas
  • Fresh root ginger
  • Fresh garlic
  • Light soy sauce (I like to use golden label superior soy, but light soy is fine)
  • Worcestershire sauce (Lea and Perrins)
  • Chinese five-spice powder
  • Chinese shaohsing rice wine (or dry sherry)
  • Pure sesame oil
  • Cornflour / corn starch
  • Salt
  • Monosodium glutamate (MSG, yeah I know I know, but the amount I use isn't going to make bits drop off you or anything...)
Begin by measuring out as much rice as you want to cook. I usually do a cup or two per person, as I tend to eat this as a meal in its own right.

Next, you need to wash the rice thoroughly. I start with a few cups in a sieve running water through it, then I transfer the rice to a pan and let water fill the pan and overflow for several minutes, until the water is no longer cloudy.

When that is done, cook the rice in the normal manner. Best results always come from a dedicated rice cooker. Err on the side of very slightly underdone rice rather than allowing it to become mushy - mushy rice does not fry well at all.

After the rice is cooked, allow it to cool for as long as possible. The longer you can leave it the better - the frying works best with cold rice. If the rice is still hot when you fry it, it will tend to steam in the wok rather than fry, which gives a different flavour.

While the rice is cooling, you can prepare the rest of the ingredients.

Mix around a tablespoon of rice wine with a good glug of soy sauce, a teaspoon of five-spice and half a teaspoon of cornflour.

Slice up the meat and place it into the mix, stirring it so all the meat is coated. Leave it for a few minutes to soak up some of the flavours.

Next, heat up a wok. For this dish, extreme heat is all important, so although those of you with 'non-stick' woks will be able to have a go at this, they never get hot enough. What you really need is the sort of wok you can pick up for about £10 ($16) from a chinese supermarket. They are made of very thin steel, start off silver in colour and are only non-stick if you use them properly!

Turn the heat to full and when the wok starts to smoke, pour in about a tablespoon of oil. I use groundnut oil, but vegetable or sunflower oil is fine. When the oil is just starting to smoke, drop in the meat and stir fry vigorously until cooked.

Remove the meat from the wok, allow it to drain for a few minutes, then slice it again into matchstick-sized strips.

Next, roughly chop the garlic and ginger together, then stick it into a processor to mince it.

Don't blitz it too hard, you still want little pieces rather than a paste.

Now it's time for the rice, so wipe down the wok to remove whatever may be left behind from cooking the meat.

Break open an egg and beat it until the yolk and white are all together, as if you were making an omelette. When this is done, heat up another tablespoon of oil in the wok and wait until it's just started to smoke. All of this is done on maximum heat.

This next part is very rapid and time-critical, so be prepared. Pour the egg into the wok and quickly move it around so as to break it up. Before the egg has cooked through (there should still be some uncooked, liquid egg in the wok) drop a spoonful or two of rice onto the egg, then quickly toss and turn the wok's contents so the rice and egg are well mixed. Add a good pinch of salt, a tiny bit of MSG and half a teaspoon of the ginger and garlic mixture. Stir fry vigorously. Do not over-fill the wok with rice, or too much heat will be lost and the food will not cook in the proper manner.

When the rice starts to take a little colour from the frying, add a spoonful of peas, some of the meat and about ten drops of worcestershire sauce.

Continue to fry the rice, keeping it moving to prevent it burning on the bottom of the wok.

After a few minutes the rice will be a little darker, though you must choose this point yourself depending upon your taste. Add a splash of soy sauce (maybe a teaspoonful?) and mix it into the rice for a few seconds, then empty the rice into a waiting container.

You will need to repeat these steps multiple times in order to fry all your rice, because you will almost certainly have prepared more rice than will fit into a single frying stint.

When all the rice is fried and set aside, drizzle a few drops of pure sesame oil into the rice and mix it in. This stuff has a very potent flavour, so be sparing!

Allow the rice a few minutes to cool, then dig in!

Om nom nom nom.

Saturday 20 June 2009

The Leap of Faith

A person told me not so long ago that I was standing on the ledge of a metaphorical window, and that I was under the impression that it was very high up. That person told me that in fact, the window was not high at all, and that I should step back off the ledge and I would find the ground a safe distance below me.

That person was wrong.

The ground was even further below than I had initially thought. The fall was long and terrifying, and when I finally saw the ground it was far from where I wanted to be.

Tuesday 16 June 2009

vBulletin Style Blogs at

I have now posted part two of my series of blogs detailing some of the highlights of the vBulletin 4 style system.

Part one dealt with markup and included some screenshots:
First Look: The vBulletin 4.0 Style

Part two, posted today, lays out some of the ways that administrators can make use of new features of the style system in vBulletin 4.0:
vBulletin 4 - Style Variables

Monday 15 June 2009

Rainy Days

I've had this account registered for a while now, saving it for a rainy day.

Check back from time to time, especially if the forecast is for storms.