Daily Archives: Wednesday 18/05/2011

How to Generate a URL containing QR code using Google Charts API CodeUnit 18 MAY 2011

QR codes are slowly, slowly gaining more traction, despite the fact that they are pretty much only useful little beasts when it comes to directing smartphone users to some or other web content URL. Generating them is pretty easy, hell, Google Chart has an API for them (which is exactly what we are going to leverage in a minute), and to decode them you simply need a phone with a camera and a decoder app installed. So let’s do this.

If you are already familiar with using the classic Google Chart API to generate graphs, then you will know that creating a graph image is pretty much hitting a Google-supplied URL and providing certain required paramters as specified by the Chart API. Because QR codes essentially work the same way as graphs do, i.e. they are produced based on the passed information, it was a fairly simple task to incorporate them into the API. One or two minor parameters added and removed (as laid out by http://code.google.com/apis/chart/docs/gallery/qr_codes.html) and you’re good to go.

To actually see this in action, let’s generate a QR code which is nothing more than an encoded URL (if hit by a smartphone, the phone should attempt to redirect to the encoded URL):

<img src=”http://chart.apis.google.com/chart?cht=qr&chs=350×350&chl=http%3A%2F%2Fwww.codeunit.co.za” />

As you can see above, only three parameters are required to generate our desired QR code. cht is to tell Google that it is a QR code, chs defines the size and chl contains the data to be encoded, in this case a URL. Note that the data needs to be URL encoded before being passed to the API.

And the result?


Karate Tip: Adding Stripes to Your Belt Martial Arts 18 MAY 2011

Here’s a handy tip for adding the necessary two or three stripes to your belt whenever you reach a level that requires that sort of distinction from the plain color of the belt.

Instead of stitching on a cross band of ribbon or material, simply reach into your tool box, pull out a roll of white PVC insulation tape, wrap that around the belt and cut off the ends to make it neat.

It sticks really well, looks very neat, and is a doddle to remove when you finally grade next and get a new ranking with that color band.

And as an example, allow me to provide a photo of my very own brown belt three, recently achieved with the surprise grading ceremony held after the Funakoshi Karate International South Africa Gushku 2011 at Oak Valley Wine Estate on the 7th of May 2011.

Pretty, isn’t it?