Archive for December, 2006

Labels with hover events

A form label with a hover styleI created a small example showing how to use the ‘label’ HTML tag to make it easier to click radio-buttons and check-boxes. People are used to being forced to click the little tiny boxes (with little margin for error) so they may not realize if a clever web designer has implemented labels for their form controls. By clicking the label, the focus shifts to the input element without forcing the user to demonstrate superior fine-motor control.

Note: The hover event does not work in IE6 or earlier without a JavaScript hack. **sigh**

Sooke Road Adventures

Big tree sleepingOvernight on Thursday we had a big storm system pass over Vancouver Island. I’m still getting moved into my new place, so I was staying in Sooke. Bad idea.

The next morning I had to drive to work along what remained of Sooke Road.Tree across Sooke Road

Morse code for Java

I was rummaging through some old files and I found a Morse Code object I wrote when I was playing around with binary trees. I thought that this might be useful to someone, so here it is licensed under the MIT license.

Testing for GD and PEAR

I was making a module the other day that had some dependencies on PEAR and GD. So I cobbled together a test for GD and PEAR from some GPL‘d code I found online. I thought that I’d share the code snips (it is all GPL licensed code by the way).

PEAR
The PHP Extension and Application Repository is a standard library of reusable PHP components.
GD
The GD library is an image manipulation library that can be used with PHP

Checking for GD in PHP

/**
 * check if GD is installed and is version 2 or higher
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 */
if (! extension_loaded('gd')) {
    echo "The GD extension was not found!";
} else {
    if (function_exists('gd_info')) {
        // use gd_info if possible...
        $gd_ver_info = gd_info();
        preg_match('/\d/', $gd_ver_info['GD Version'], $match);
        if ($match[0] < 2) {
            echo "This program needs GD version 2 or higher to run properly.";
        }
    } else {
        // ...otherwise use phpinfo().
        ob_start();
        phpinfo(8);
        $info = ob_get_contents();
        ob_end_clean();
        $info = stristr($info, 'gd version');
        preg_match('/\d/', $info, $match);
        if ($match[0] < 2) {
            echo "This module requires the GD Library version 2 or higher.";
        }
    }
}

Checking for PEAR in PHP

/**
 * check if PEAR is installed
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 */
if (!class_exists('PEAR') || !(@include 'PEAR.php')) {
	echo "This module requires the PEAR Library.";
}

The big owl

Big owlThis morning at 0600h, I left my house to go to work. Swoosh! A big owl flew by my head and landed in nearby trees. This was a big bird! I reached into my satchel and took out my omnipresent digital camera.

I managed to take two photos before the owl flew off, dazed from the flashes; only one photo turned out.