Monthly Archives: March 2007

Accessible Tag Clouds


The example programmes presented here came about as the result of a thread on the GAWDS mailing list.

Example PHP Programme and Code Listing

The programme tagcloud.php demonstrates how (X)HTML ordered lists may be produced and styled visually as ‘Tag Clouds’ – where terms are presented in an arbitrary order and weight is given purely visually – and ‘Tag Wedges’ – where a logical sequence is used and weight is given by position in sequence. Tag Wedges may also be styled visually to provide further emphasis. To see how I made this work, have a look at the PHP code listing.

Real-World Example

In addition to the dummy data example described above, I have also created another example which is the same in all details other than the data being produced by an SQL query of the Smiffy’s Place database. Have a look at the categories
tag wedges and cloud
to see this real-world example.

And Finally…

To complement the real-world example and based on the same code, here it is again, in SVG. The reason that I have done this SVG rendering is that I feel that if we are ever going to produce an accessible, semantic, graph to do the job of a tag wedge/cloud, this will probably be the means to do it. (Please note – this is my first ever brush with SVG, so it is not pretty.)
UPDATE: I have now fiddled some more with the SVG so that it
looks a little better. Between Firefox and Opera, Opera
gives a much better rendering.

Please leave any comments on this topic against this post.


I have, for some time, used perl -e to do simple calculations on the Unix command line. This method has its drawbacks, so I have written a wrapper that still performs evals of given expressions, but adds the functionality of the Perl Math::Trig module, persistence of variables between sessions and a few other bits and pieces that I find useful.

SmiffyCalc may not be for everyone – whilst it is still a Perl eval at heart, the syntax is an unholy mixture of Perl, SQL (especially some new bits I have planned), Bash and you name it. Something of a mongrel application, a bit like PHP <wink/>.

The application can do all the same damage that Perl can do in the wrong hands so should not be run as root, whilst drunk or by the type of user who would be more at home with a Fisher Price Activity Center, er, Windows. That said, it may be useful to someone, especially of the Unix/Perl/Geek type, so it may be downloaded here, under the terms of this Creative Commons License.

Bug reports – or even better bug fixes – most welcome. Feature requests may be addressed if I’m likely to find them useful myself. (I did, after all, write this tool for my own purposes.)


A slightly revised version has been posted at PerlMonks.

Saying "Whoops", Nicely

A Tragedy of Errors

In the early days of the Web when most content consisted of static HTML
pages, the type of errors that we encountered were generally
HTTP status codes, most famously "404 – Not Found". Web servers today still use the same status codes (HTTP has changed little) and – out of the box – produce error pages that are less than helpful to the average, human, visitor.

Whilst these status pages (not all the codes are indicative of an actualy error) might be less than helpful for us humans, the
status codes contain important information which can be used by
software user agents such as search engines. Indeed, the user
agents with which us humans usually interact – Web browsers –
could be coded to respond to HTTP status codes in a more
informative way.

There is something far worse than a terse "500 – Software Error" – receiving an error message with a status code of 200, which implies that the page has been found and is OK but merely says "Could not connect to database". With the increasing use of the PHP language, which tries its utmost to send HTML content, sloppy programming is liable to give rise to errors – often meaningless to the site visitor – being served as good pages.[1]

To make our sites more accessible and usable, we need a nicer
way of saying "whoops!"

Catching Errors, And What To Do With Them

Before dynamic content (that generated by software rather than
static HTML pages) is released to the public, it is hoped that
a certain amount of testing will be done to make sure that it
works. This testing, however, often fails to address runtime
errors which may occur when something breaks in operation – most
often a database connection.

As developers, showing a database connect error can be very useful.
The general public, however, is not interested; all it knows is
that the site at which it is looking is broken. Worse still, I
have seen error messages on sites that reveal far too much about
the inner workings of the software, possibly exposing
vulnerabilities to any visiting villains.

How should we address this? I would suggest that we should take
the following steps:

  • Ensure that anything that can throw an error is tested when
    called and an error-handling routine called if the test fails.
  • Provide a means by which we can easily switch our software in
    and out of debug mode. (A variable at the top of the programme
    along the lines of $debug=TRUE is a good way.)
  • Error handling routines should look at whether debug mode is onor not and either serve an informative error page for the
    developer, or pass an appropriate HTTP status code to the user.

Making "Whoops!" More Helpful

Those who only write static Web content and who fell asleep in the last section can wake up now – this part is relevant to you.

In the previous section, I explained how we can work around the
recent problem of software presenting errors as not errors, taking us back to our original issue of HTTP status codes and how they can be less than helpful to the general public. Let us now have a look at how we can make those codes work for us, inform our visitors and make our sites more accessible.

Know Your Web Server

Even if we are not involved in programming, some knowledge of how the Web server on which our content is hosted is configured can be important. As an inveterate user of the
Apache HTTPD server
software, the examples I present here will refer to that software.
Those using other Web servers, read the documentation or use
Google to search for specifics.

The Apache HTTPD allows us to specify our own pages, programmes or
scripts to handle errors, using the ErrorDocument directive. The
following example will direct 404 (not found) errors to Google. This is
not a helpful thing to do and is given for illustration only.

ErrorDocument 404

Custom error pages can be a good way to make our sites more
accessible when things go wrong.

Custom Error Pages

Now that we know that we can tell our Web server to call a custom page
when we get an error, what should we actually do? If we are serving
static HTML, we can provide informative pages suggesting what the
visitor might want to do next – whom they can contact for further
information or how to search for what they want. (A Google site search
form could be incorporated into a static 404 error document, for example.)

For those of us writing dynamic content, custom error pages are
where we can really start to make things happen. We do not need to write
a separate programme/script for every possible error – we can just use
one and feed the error code through the query string:

ErrorDocument 404 /errors.php?e=404
ErrorDocument 500 /errors.php?e=500

Here are a few things that we might consider doing with an error
handling programme:

  • When handling a 404 error, look at the requested URI and suggest
    possible alternatives.
  • When handling a 404 error, suggest that the visitor might like
    to visit a site map or site search facility.
  • When handling a 404 error, examine the requested URI for
    patterns that might suggest an XSS
    attack and warn somebody.
  • If we cannot connect to a database, send a 500 error page, but
    tell the visitor that the site is temporarily unavailable (do not say
    why – it can look bad), and provide contact information should they
    need something urgently. At the same time, send an e-mail and/or
    an SMS, using an online
    provider, to the site administrator rather than relying on a visitor
    to report the problem. The same could apply to any other failure of
    an external service upon which our site relies. If we are acting
    on the failure of an external service such as a database connection
    we must not make any calls to that service from our error handling
    programme! Error handlers must be able to stand-alone.

A Final Word on 404s

A frequent cause of 404 errors (and thus having to handle them) is the removal of pages, or conversions to different URI schemes. In the words of Sir Tim Berners-Lee,
Cool URIs don’t change.

If pages must be moved or removed, be certain to set up rewrites/redirects (another reason we should Know Our Web Server)
so that the visitor, at the very least, is directed to a page explaining
where a document has gone and why. It is suggested that readers acquaint
themselves with the HTTP status codes referenced at the beginning of this
article, in particular with the ones beginning with the digit 3.


By whatever means we are serving our content, let us ensure that when things go wrong, we provide information that is helpful to the site visitor – not to developers or hackers.

Smiffy, as always, is available to consult for those who
require help in saying "whoops", nicely.


  1. In my early days of writing Web applications, I used Perl (and still do when PHP is not specified). Whilst PHP will send content even when there is something fairly major wrong, errors in Perl coding often as not break completely, causing the server to send a 500 status code – a fairly obvious sign that something is broken. I am not criticising PHP, merely pointing out that it requires a little more care to code.
  2. If using debug mode in a visual environment, it is a good idea to have some code that writes "Debug Mode" in large letters at the top of each page to make it harder to forget to turn it off before deployment, which can make one look rather silly. Calling debug mode from the query string is another option, although there may be certain security implications.

The Perils of Gluten-Free Baking

Gluten-free cooking is not all fun and games; I know this from my own experience and have also had it confirmed by a professional chef. It is, in fact, a challenge or a pain if one is feeling in a less-than-positive mood.

Apart from baked fare and pastas, I have never been a huge wheat user. Sauces can thicken quite happily with maize starch (cornflour), rice or tapioca flour, buckwheat flour makes a better coating batter than wheat ever could, and I have had good results with pastas made from maize and amaranth. Breads and pastries have been, and remain, the greatest challenge.

Whilst I have had some reasonable results with gluten-free bread, an attempt today to reproduce my best yet batch was a total disaster. The photograph shown here has a whisk standing in the loaf, just to show how total was the collapse. I have been fighting collapses and holes all along. The bread machine that I am using has an unfortunate habit of doing a quick stir at the end of the last rise. This would be fine if we were dealing with a dough but, as we are actually dealing with a fragile batter (think soufflé), that little twirl is enough to collapse the area immediately above the paddle creating – at best – a small void or – as found today – a total collapse of the loaf.

Only this morning, I was wishing that the bread machine could be hooked up to a laptop and be re-programmed with a gluten-free cycle. (If it weren’t for my poor state of health, I have an old machine in my office that I would very much like to modify, installing my own control hardware/software.)

photo of handmade gluten free loaf

Software/bread cycles apart, today’s disaster shows just how critical tiny factors are in achieving success with gluten-free bread. I do not know what caused today’s collapse – I am weighing to within a couple of grammes, so the quantities should be about as close as they should be. Variables such as water temperature, a new batch of yeast and accuracy of temperature control in the machine could all play a part.

I am beginning to tire somewhat of never really knowing what to expect batch to batch. Bread machines are great for wheat-based breads, but less than optimal for those lacking gluten. As we are now coming into winter and it is cool enough to operate the oven, I am inclined to keep using the bread machine to do all the hard work of mixing, but to start proving and baking in the oven, where there is nothing (barring earth tremors) to disturb the risen batter at that critical time.


The second image on this page is of a gluten-free loaf mixed in the bread machine, then poured into a bread tin and baked in the oven. This loaf rose well and even looks more like bread than the normal gluten-free offerings. Unfortunately, my mobile phone has no exposure control on its camera, so this picture is the best I could produce, aided by some Picassa retouching.



Due to a delay in shipping, some gluten-free goodies that my wife had ordered failed to arrive yesterday (Friday), leaving here without for the weekend. As my gluten-free breads have been improving with every batch, I thought I would have a crack at making a gluten and dairy free fruitcake. Herewith are the details of the experiment.


  • 150g maize courflour
  • 75g green pea flour
  • 75g chickpea (besan, gram, urid) flour
  • 75g rice flour
  • 75g tapioca flour
  • 200g brown sugar (I used a mix, mostly dark brown)
  • 160g vegetable oil (I used peanut, others may need to change if intolerant)
  • 460g water
  • 4 eggs
  • ½ packet dried yeast
  • 1 teaspoon (about 2g) guar gum
  • 1 pinch salt
  • 1 pinch ground cinnamon or cassia
  • 1 pinch ground ginger
  • 3 – 4 cups mixed dried fruit


  1. Pass the flours, gum and sugar through a sieve into a bowl, introduce yeast, then mix well with a (dry!) hand whisk.
  2. Add oil, water and eggs to the pan of a bread machine.
  3. Add flour mix to bread machine pan, salt and spices going in on top.
  4. Operate bread machine on dough cycle, adding fruit at the appropriate point (our machine beeps).
  5. When mixing has stopped, transfer resultant batter to a baking tin, ensuring that the fruit is spread evenly across the bottom.
  6. Prove in a warm place for about 45 minutes. I used the oven, only just switched on.
  7. Turn oven on with cake inside, bake for 1 hour or so, when it reaches temperature. Using our fan oven, I did this at 150 degrees Celsius.

Results and Observations

The cake rose well and came out sufficiently moist, and with a good texture. All the fruit, however, was at the bottom. I believe that a thicker batter (less water) may be able to remedy this.

I baked the cake in a spring-form tin, lined with greaseproof paper. This prevented any problems getting the thing out of the tin at the end. My experience has shown that gluten-free bakes can be rather fragile when still hot, so an easy release can be important. I peeled the paper off the side as soon as the cake was out of the oven and the tin; however, I did not attempt to remove the paper from the base for about 20 minutes after that. The paper was removed by covering the cake with a plate, inverting, removing the cooling rack and paper, replacing the cooling rack, then righting it again and removing the plate.

My wife liked the cake, but my sensitive pallet could still detect the chickpea flavour, which put me right off it. (I can also taste the soy in commercial gluten-free products that contain it and don’t like them either.)

MySQL Meets OpenOffice

MySQL staffer, Roland Bouman has written this post on how to get OpenOffice to work with a MySQL datasource, complete with screenshots. Until I read this, I was struggling; five minutes later, I was in business, hooked in using MySQL Connector/J. (Whilst there is an ODBC implementation available for Unix, it is generally easier to use this Java (JDBC) version.)

I can now use OpenOffice Calc to graph and present my data (body temperature records that I am keeping for my doctor), but let MySQL take on the burden of storing and querying that data – something that was slowing this particular spreadsheet down, due to the volume of data and number of graphs used. Well done, Roland.

Waffles Are Go!

After the waffle disasters of yesterday, I sought help on the Recipezaar Community Forums to see what exactly had gone wrong. I was duly advised that my batter was too thin (despite the recipe I had based it on saying that it should be), and that it needed more oil. After another arduous session cleaning the machine, I applied the advice given and was greeted with success.

The Waffle Recipe

  • 1 cup “Lola’s All-Purpose Gluten-Free flour
  • 1 egg
  • ½ cup water
  • ½ cup vegetable oil
  • ½ teaspoon guar gum
  • 1 teaspoon gluten-free baking powder.
  • Salt

The ingredients are beaten together, then the resultant batter refrigerated for 2 hours. Batter is then ladled (about half a cup) onto the heated and oiled waffle iron. Batter is spread carefully to cover the surface of the die, without overflowing the outer edges (this causes the lid to be hard to open). The lid of the waffle iron is then lowered carefully – do not push it down, otherwise the batter can come out of the sides, stick and make it difficult to open. (Guess how I know.) Cooking time with this old Sunbeam waffle iron is just under 5 minutes.

I have repeated this using rice flour, rather than the blend, with similar success (slighly more water is needed).

Sincere thanks to “Chef TotalFark” at Recipezaar for the valuable advice that got this working, and saved any more horrendous cleaning jobs.

Smiffy Waffles On

Photo mess in waffle machine
Mess #1

Up until today, I had never seen a waffle, let alone made one. I have only seen them made (or consumed) on The Simpsons, so that probably doesn’t count for much in the way of culinary instruction.

My wife had acquired a waffle maker through eBay – it appeared pristine and unused, and I really wish that I had taken a photograph before I trashed it.

I started off making a batter of egg, water, gluten-free baking powder and a flour based on chick peas, rice, tapioca and potato (from Lola Workman’s Wheat Free World book). The waffle maker was duly oiled and fired up. Once up to temperature, I added batter, shut the machine, sat down and waited. After just over three minutes, I opened the machine and found batter completely adhered to both the upper and lower cooking surfaces.

Photo of slightly less mess in waffle machine
Mess #2

Now waffle machines are self-heating; this means that cleaning the cooking surfaces cannot be achieved simply by dropping the whole thing into a sink of water for a few minutes – and neither are the cooking surfaces detachable. The instruction manual says quite glibly that a wipe with a damp cloth is all the cleaning that would ever be needed. Really? If only that were so. I will not go into the cleaning process that I had to apply, but would say that it took me an hour and 20 minutes.

Whilst I was doing that, I cooked up two lots of the batter in my pancake pan, and produced a very passable naan bread.

What went wrong? More reading and reasoning led me to think that, firstly, the batter was too thick and, secondly, I should have used more oil in the batter. I corrected what remained of the batter and tried again. It stuck again, but not quite so badly. What could be prised out and eaten was actually quit nice.

The waffle machine is now sitting awaiting another cleaning, hopefully not such a long one this time. No further experiments will be conducted until I have done considerably more research.

I concluded the cooking session by making myself some bread. Working with wheat flour can be absolute bliss after the efforts of cooking gluten-free. And I just can’t wait for that St Padraig’s Day Guinness tonight.


I have now received some advice from a professional – next attempt will be when I have cleaned the machine. Results will appear in a future post. is an initiative of Wageningen University in the Netherlands a very useful resource for those seeking information on food additives, food safety, food production and more.

For Australians and others looking up food additives, just add an E to the beginning of an additive number and find it under the E-numbers section.

Beannachtaí na Féile Pádraig oraibh!

Beannachtaí na Féile Pádraig oraibh! – St Padraig’s (Patrick’s) Day blessings be upon you! (Even to those people who are seeing strange characters because they are not using Unicode fonts.) Yes, we are now over half-way through March and just four days from the Equinox.

As I went out into the vegetable garden this morning to see what was ripe to harvest, I felt a pleasant cool, crispness in the air that made it feel like Autumn really is with us. This is especially so, seeing that my largest courgette (zucchini), which I am keeping for seed, is now a fine, ripe, yellow, that reminds me of Harvest Festival in my primary (elementary) school days. Hopefully days like yesterday, which was hot and humid, and the day before, which was hot and windy with dust storms, will become less frequent as we begin the journey into Winter.

Tonight I will be able to enjoy my Guinness, reflecting on past days of doing the same in Dolphin’s Barn (Dublin/Baile Átha Cliath), just a stone’s throw from the holy of holies, St James’ Gate, the Home of Guinness on Earth. It was in Dublin’s fair city that I first ate Lebanese food, discovered Gewurtztraminer at a Chinese restaurant and spent a whole day sitting round waiting for a Cisco cable to arrive, only to discover that it had actually arrived in Berlin. (DHL could not be blamed – the last three letters of both cities are the same.)

Enough of these nostalgic musings, I’m supposed to be catching up on some cooking today. Slánte!