Monthly Archives: April 2015

new jQuery Plugin – Equal Height Columns

Have you ever been in the situation where you need to use floated columns on your web page and want them all to be the same height as the tallest column? If you have, then you will probably know that you can achieve it with CSS. However, I don’t like this approach, and quite frankly have never understood it fully anyway. As I used jQuery in practically every project I write I thought it would be neater to just write a jQuery plugin which would do all of the hard work for me.

Here is the plugin code:

 /* * @Copyright (c) 2013 James Stoddern -  
 * Permission is hereby granted, free of charge, to any person  
 * obtaining a copy of this software and associated documentation  
 * files (the "Software"), to deal in the Software without  
 * restriction, including without limitation the rights to use,  
 * copy, modify, merge, publish, distribute, sublicense, and/or sell  
 * copies of the Software, and to permit persons to whom the  
 * Software is furnished to do so, subject to the following  
 * conditions:  
 * The above copyright notice and this permission notice shall be  
 * included in all copies or substantial portions of the Software.  
 * How to use it:  
 * If you have a series of floated columns, which you wish to make the same height, give them all the same  
 * class, and then run the plugin. It will determine the tallest div, and equalise the height of the rest  
 * $('.selector').equalHeights();  

(function( $ ) {
    $.fn.equalHeights = function() {
        var tallestElement = 0;
        var startRow = 0;
        var elements = new Array();
        var $currentElement;
        var topPosition = 0;

        this.each(function() {

            $currentElement = $(this);
            topPostion = $currentElement.position().top;

            if (startRow != topPostion) {
                for (currentDiv = 0 ; currentDiv < elements.length ; currentDiv++) {

                elements.length = 0;
                startRow = topPostion;
                tallestElement = $currentElement.height();

            } else {
                tallestElement = (tallestElement < $currentElement.height()) ? ($currentElement.height()) : (tallestElement);


            for (currentDiv = 0 ; currentDiv < elements.length ; currentDiv++) {


}) ( jQuery );

So how do you use it?

Well, firstly copy the plugin from this page, and save it to a folder where you normally keep your jquery scripts. I usually call it jquery_equalheight.js. After you have included jQuery in your page, simply inlcude the plugin as well.

Next, all you need to do is run the plugin against a selector. In the case of your columns, make sure they all have the same class and then add this neat bit of code to run the plugin.



Store your snippets with Github Gist

If you are coding a lot then you probably have chunks of re-useable code which you copy and paste into your applications to save time. These are what we refer to as “snippets”. There are a number of ways you can store these, for example in a text-file on your desktop, or the IDE in which you are working. However, if you are working on a different computer, will these snippets be available to you? Unlikely, unless you duplicate them. Then of course, if you need to edit your snippet, you need to make sure you update it everywhere else you might have a copy stored.

bye bye problem, enter GitHub

Our friends at GitHub have come up with the solution, and named it Gist. This is essentially a free online and version controlled area for you to save your snippets. You can create a new snippet (either public or private) and then paste your code into it. Wherever you go, these snippets are available to you, and if you want to update them you can.


SEO friendly urls in codeigniter – the challenge

Codeigniter is generally quite good at providing friendly urls, mainly due to its url segment approach. Instead of the traditional querystring approach where parameters are passed as follows:


codeigniter uses segments instead.


So the segmented approach is much friendlier but still not perfect. What I want to achieve is a much more descriptive url such as “view-my-account.html”. In order to achieve this I decided to generate a ‘slug’ (usually a hyphenated string in lower case) for each post as I create or edit them in the cms. The slug is a friendly version of the blog post title as can be seen below. This is stored in a column called “slug” in the database for use later.


The intention is to have my controller perform a database or file-cache lookup for the slug, and then route it to the correct controller.


One of the first challenges is to tame the Codeigniter routing system, which allows urls to be directed to the correct controllers and methods. Routes can be managed inside of “/application/config/routes.php”. In order to dynamically route the first step is to add some extra code in the routes.php to handle dynamic routes:

// include the dynamic routes from the cache file

We also need some way of actually generating these routes, so what I decided to do was generate them when posts are created or updated. After the new post has been written to the database, a new record is created that contains the friendly url, the Slug, and the route that it should be directed to. In my blog this model is quite straight forward and comprises of the segments “blog/category/postid”. So in my add/edit posts I have some code like this

//update the record for the dynamic route
$dynamic_route = "blog/index/" . $category . "/false/" . (int)$id;
$route = array(
    'post_id' => $id,
    'route' => $dynamic_route,
    'slug' => $slug

$result = mysql_query("SELECT * FROM routes WHERE post_id='{$id}'");
$num_rows = mysql_num_rows($result);

if($num_rows > 0) {
    //update the record
    $this->db->where('post_id', $id);
    $this->db->update('routes', $route);
} else {
    //insert a new record
    $this->db->insert('routes', $route);

Now that the route has been generated we have to make it accessible to Codeigniter somehow. To save on database queries I have decided to write all of the routes for the site into a file cache – this lives inside “application/cache/routes.php” and effectively contains an array of all the routes for the site. I did this with a new model called “Router_m” which has a method called “cache_routes()” which looks as follows:

class Router_m extends CI_Model {

    function __construct() {

    //grab all of the routes from the database, and cache to a file
    public function cache_routes()
        $query = $this->db->get("routes");

        foreach ($query->result() as $row)
            $data[] = '$route["' . $row->slug . '"] = "' . $row->route . '";';
            $output = "load->helper('file');
            write_file(APPPATH .  "cache/routes.php", $output);

This cache file is loaded by “config/routes.php” after the static routes have been defined. The file looks like this:

$route["new-single-whore-left-me.html"] = "blog/index/musician/false/27";
$route["content-management-system.html"] = "blog/index/blog/false/3";
$route["inline-ajax-image-uploader-for-tinymce.html"] = "blog/index/developer/false/45";
$route["jumping-on-the-bandwagon-youtube-videos.html"] = "blog/index/blog/false/41";
$route["test-post.html"] = "blog/index/blog/false/46";
$route["seo-friendly-urls-in-codeigniter-the-challenge.html"] = "blog/index/developer/false/44";
$route["big-brother-is-watching-google-analytics.html"] = "blog/index/blog/false/42";
$route["new-image-uploader-plupload.html"] = "blog/index/developer/false/43";
$route["sublime-text-2-video-intro.html"] = "blog/index/developer/false/40";
$route["multiband-compression.html"] = "blog/index/musician/false/39";
$route["store-your-snippets-with-github-gist.html"] = "blog/index/developer/false/38";
$route["on-fire-with-sparks.html"] = "blog/index/developer/false/37";
$route["sublime-coding.html"] = "blog/index/developer/false/35";
$route["my-new-guitar.html"] = "blog/index/musician/false/36";
$route["a-moment-of-clarity-literally.html"] = "blog/index/musician/false/33";
$route["song-writing-basics.html"] = "blog/index/musician/false/15";
$route["codeigniter-language-packs.html"] = "blog/index/developer/false/29";
$route["are-you-listening-to-your-speakers-or-your-room.html"] = "blog/index/musician/false/34";
$route["the-importance-of-gain-staging.html"] = "blog/index/musician/false/32";
$route["the-studio.html"] = "blog/index/musician/false/30";
$route["the-subjective-part-of-mixing-your-own-vocals.html"] = "blog/index/musician/false/28";
$route["implementing-tinymce-as-your-rich-text-editor.html"] = "blog/index/developer/false/2";
$route["welcome-to-jamesstoddernnet.html"] = "blog/index/home/false/26";
$route["new-single-out-now-smile.html"] = "blog/index/musician/false/14";

Of course, to make use of all this routing, I have had to change the links on the site, so that in the “recent posts” panel for example, instead of building a traditional codeigniter controller/method style link,  the slugs can be used directly. As soon as you navigate to the slug, its correct location is loaded from the routes cache. Of course the user doesn’t know this and just sees the friendly title. I have also got the page title to be set now from the post’s title as well to make everything even more friendly.

Orange OR15 tube amplifier – USA 110v to UK 230v voltage switch

I was lucky enough in December 2014 to find a used Orange OR15 head in the Las Vegas Guitar Center. poserHowever, before purchasing gear like this from over the pond it is necessary to know whether it can be switched to run on the UK voltage. Some guitar amps are fixed to a 110v USA and others on set to the 230v UK voltage. If you buy a USA amp which is fixed to 110 then you might have problems. In some cases I have heard that the internal power supply needs to be converted.

Luckily, the OR15 head does have a voltage selector switch – although it is not in a very accessible location. In order to get to it you need to remove the amp from the case – the voltage selector is tucked away on the side of the amp.


Remove the amp…

First remove the bolts from the feet – these go all the way through the feet, the wooden case and screw into the amp body itself. Once these have been removed you can slide the amp out gently – be careful not to damage the tubes on the way out. On the left side of the amp (looking from the front) you will find a red selector switch – 110, or 230. Switch it over to 230v if you want to use it in the UK.


Change the fuse…

Wait, that’s not all though – you also need to switch the fuse over, as the USA fuse is rated differently, and as you are now going to use your amp in the UK, you need a higher rated fuse. Using a flat screwdriver you can remove the fuse case from directly below the power cable socket. You should find two fuses in here. One of them should be a T500ma fuse – make sure this is the one that’s in use.



Remember, if you are not confident doing this kind of thing you should take it to an experienced electrical technician or your local guitar shop. There are extremely high voltages in tube amps so you can get a severe shock if you don’t know what you are doing.

Tilley lamp cleanup

I was clearing out some junk in the garage today and came across an old Tilley lamp, covered in cobwebs and dirt it was. So when I got it back home I dismantled the lamp to take the glass bowl out and gave it a good wash in soapy water.


After brushing all the dirt of the lamp body I just used a bit of metal polish wadding. I wanted to retain a fairly worn look so there was no attempt to make it look like a new lamp. I’m quite pleased with the results and now have it hanging outside my log cabin door. Very nice!


Carl’s Jr. – Single Mile High Bacon Cheeseburger

The Single Mile High Bacon Cheeseburger with thick-cut applewood smoked bacon on a charbroiled beef patty.

This is a stunning burger which I enjoy at the end of my Las Vegas vacations, due to the fact that there is a Carl’s Jr. in McCarran International Airport.

There is nothing to complain about this burger – in fact I would say that this is the only restaurant grade burger I’ve ever had from a fast food burger outlet. This wipes the floor with a McDonald’s any day of the week, although the prices are higher in Carl’s, so you would expect that.

I have stupidly never photographed myself eating one so I’ll have to make do with one from their website for now.



Johnny Rockets – Bacon Cheddar Single

Smoked bacon, double cheddar cheese, iceberg lettuce, fresh tomato, white onion & special sauce.

This is still my favourite burger, so far nothing else has topped it. I enjoy eating a JR each time I visit Las Vegas, as there just happens to be a diner in the Flamingo Casino, where we often stay.

This burger is just packed full of flavour and made on demand so always fresh. It comes with the usual salad items inside the burger. The patty’s are huge, so even in the single configuration as shown below, there is plenty to eat. The buns are amazing as well, and have a slight polish to them.

This is the benchmark by which I compare all other burgers.



Wetherspoons – Cornish Burger

I really like Wetherspoons – I think some people slate it, but that’s just because its just fashionable to do so.

Their Cornish burger is one of my favourites – I like fairly straight up burgers, and this is a damn good one. A nice thick patty which is not greasy, topped with a couple of nice rashers of bacon, a might thick slice or two of Davidstow cheddar and then some onion rings.

As usual it comes with a pint and a side of fries and onion rings. All for 7.49, so you can’t complain – a pint of the black stuff costs half that, and you can have that with your burger if you want. Nice one Tim, keep it up.


Hub Box – Truro

My friend James recommended trying out the Hub Box in Truro, so off I went with my bestie Kirsty. I opted for the regulatr cheeseburger type thing and a side of fries. I was very impressed although I think I put a tad too much salt on the fries.

The burger was cooked to perfection really, nice thick patty – no grease, and it was really nice to see some rustic style fries rather than the ones you buy in the super market. The Hub box started in a shipping container in Truro but have now moved to new premises. The staff were really nice and friendly.

I haven’t been to any yet, but they have regular music nights which look quite cool – they might be a bit to cool for me, but maybe I’ll see if I can tempt the wife to go and watch a band and have a bit of scof! Not sure if they do any Veggy options though !
Hub Box

Cheesecake Factory – Mac ‘n Cheese Burger

I very seldom choose anything in the Cheesecake Factory other than their special “Chicken Madeira”, but on this occasion I decided to try their burger. This little beauty is a mac ‘n cheese burger. It features a regular 6oz patty with a deep fried macaroni cheese blob stuck to the top.

If I’m honest it was delicious but very rich – not sure I’d try this model again. It also came with a garlic dinner bread, a bucket of fries and the usual rabbit food.