Debugging with audio

By Andreas Jansson | 08 September 2011

echo "here";

Sometimes you just want to know that you took the right branch in an if statement, or that the value of a variable is what you expect it to be. Sometimes you don't have the need, time or incentive to fire up the debugger, you just want to dump a few variables to stdout. That works really well if you're writing a CLI script and it's okay if you work on old-fashioned HTML, but when it comes to debugging AJAX requests, it's pretty useless. When the response comes back to the browser you have to open up the web inspector and look at the network activity to find that particular requested document, click to look at the contents and dig out that debug message from the raw source. Not fun.

Read more »


By Zdenek Machek | 01 September 2011

Every PHP developer will sooner or later face a request to output a document as a PDF, XLS, DOC or ODF. Exporting each format by hand is as time consuming as it is dull - especially things like point-by-point positioning of elements in a PDF. So how can we get around this tedious chore using PHP?

Read more »

Writing MySQL functions in C

By Andreas Jansson | 15 December 2010

In the previous post Zdenek explained how to use MySQL stored functions to calculate the distance between two points on the lat/lng plane. Here I take his function as a starting point to describe how to implement user defined functions written in C, and import them into MySQL.

User defined functions (UDF) are compiled C functions that you can use as normal functions within MySQL. UDFs have a number of advantages over stored functions written using SQL, the most important being improved performance and the fact that you can use them as aggregate functions (like you can with SUM(), AVG(), etc.).

Writing UDFs is easy. So is compiling and importing UDFs into MySQL. First you need to do a little bit of setting up. This is how you do it (in Ubuntu and Red Hat).

Read more »

Automatic geolocation and SQL

By Zdenek Machek | 16 November 2010

Geolocation previewRecently we launched a website and platform for iGo Gift Vouchers. One of the screens shows an interactive list of the shops where vouchers can be used. The classic interface design pattern for this is to ask users to provide a postcode, or the name of a city or town, and then display the shops in that area on a map.

As usual, we decided to try something new and improve a little on the traditional functionality. We wanted to automatically detect where the user is right now, so we can display shops in their area as soon as they arrive on the page, without them having to enter any information. You can see how it works at - when your browser asks if you would like to share your location with the page, just click the option to accept.

So why Geolocation and SQL? The first part of this task, identifying where the user is, is handled on the client side usining JavaScript. But SQL comes in as the best and fastest tool for the second part of the task: identifying which shops are nearest and should be displayed on the map.

Read more »


By Nick Nettleton | 24 April 2009

apache_prettify adds code colouring and line numbers to Apache configuration code - the stuff you write in httpd.conf and .htaccess. Most useful if you are publishing this sort of code in your blog.

  • Written in JavaScript - works in the browser
  • Dead easy to use
  • Compatible with all JS libraries - jQuery, prototype, etc
  • Quick - just a couple of regexs
  • Lightweight - 1.35K minified
  • To change the appearance, just edit apache_prettify.css

Read more »


By Nick Nettleton | 24 April 2009

A bit like phpinfo() for Apache, apacheinfo tells you which Apache modules you do (and don't) have installed. Especially useful if you don't have access to httpd.conf, or you can just drop it in a password-protected admin area for quick reference.

Read more »

jquery fadeLoad plugin

By Nick Nettleton | 23 April 2009

A tiny little jQuery plugin - works just like jQuery load(), but combines it with a nice, subtle fade out/in transition.

Also includes the fix for the IE cleartype fade bug.

Read more »

Validate a credit card number in JavaScript

By Nick Nettleton | 12 August 2007

When you're writing web apps, it's good to do validation both in the browser and on the server side. Do it in the browser to provide your user with instant feedback, and on the server for real security, as all client-side validation can be tricked or circumvented by those who know how.

Validating credit card numbers is a little tricky. They all follow a special algorithm, whose name I forget. But here are the mechanics of it...

Read more »

Intro to microformats

By Nick Nettleton | 08 July 2006

Microformats are an important  - no, very important - new idea on the web. In fact, I think they are so important, they could precipitate a leap of evolution more important than AJAX and as important as XML web services. But first, an introduction.

The focal site for microformats,, is not clear at all on what microformats are, but here is my understanding:

Microformats build on the semantic capabilities of the web, using existing standards.

Unless you're fairly technical, that's probably meaningless. So, to explain. <h1>, <h2>, <p>, <ul> - all of these and other HTML tags are designed to tell human readers, web browsers and other HTML readers what sort of information they contain. Not what it looks like - that's what CSS is for - but how that bit of information relates to other bits on the page. Is it a heading, a paragraph or a list of things?

Read more »


By Nick Nettleton | 04 July 2006

Brighter by the dozenA month or so ago, we were putting the finishing touches to the Lena White website, which sells OPI nail lacquer, among other things.

Lacquer is all about colour, so we wanted to give shoppers a way to quickly and visually browse all the available colours with colour swatches, rather than the more traditional product shot route. This makes particular sense because all lacquer bottles look pretty much the same, photos of them give a poor impression of the actual colour, and they take up way more screen estate than is helpful to anyone.

Read more »