Easy chained select lists using Zend Framework and Prototype

Building a set of select lists that are dependant of each other can be a daunting task, but for a simple two-level list – in that what you select from one drop-down will changing what’s displayed in one or more other drop-downs – is actually quite easy thanks to Zend Frameworks and Prototype, both of which support Json.

Continue reading “Easy chained select lists using Zend Framework and Prototype”

Did you like this? Share it:

Create a random thumbnail of a video file

Create a random thumbnail of a video file

Looking at sites like YouTube, you may think it’s quite hard to create a lot of different thumbnails from video files, and have them from random times within that file. But, no, it’s not! As this article shows, by using the very fabulous FFmpeg library, it’s actually a very short amount of code that’s required to create all those lovely random thumbnails.

Continue reading “Create a random thumbnail of a video file”

Did you like this? Share it:

Slider – part 2 – using a mouse wheel

Following on from the previous post, I thought it’d be nice to have the handle move on a mouse wheel. Looking around for mouse wheel integration, it seems that it’s only a short amount of code to update Prototype to use the mouse wheel. Why it’s not in the core code I don’t know, as it seems rather handy. The mouse wheel code is listed at the Prototype Event Extension article over at Ajaxian.

Continue reading “Slider – part 2 – using a mouse wheel”

Did you like this? Share it:

Scriptaculous slider trick

Yesterday I was looking at the Scriptaculous library, in particular the slider bar. I had used it once before with some success, using a graphic for the track and gripper. But that’s was boring! What I wanted was to see the bar fill up with colour when it was slid. Something like this:

Slider demo

I hadn’t seen anything like this around (not saying it hasn’t been done, just that I hadn’t seen it!), so after a bit of playing I found out it was actually very easy to create. And this is how I did it…

Continue reading “Scriptaculous slider trick”

Did you like this? Share it:

Validate a UK postcode

You’ve probably seen this before, if not a thousand times, but here’s a simple function to check the format of a UK postcode.

function valid_uk_postcode($postcode)
{
    return (preg_match('/^([A-PR-UWYZ][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {0,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$/i', $postcode)) ?
        true : false;
}
Did you like this? Share it:

HTTP status codes

Quite often I find myself having to send a HTTP status code in the PHP I’m writing. This typically comes down to usually a ‘Forbidden’, ‘No Content’ or a redirect. The trouble is, I usually can’t remember the exact code of text used for the slightly more obscure codes, or at least the ones I don’t use often… Well, even for the ones I use often, if truth be told!

So I put them all in the following function which you may find useful, too.

Continue reading “HTTP status codes”

Did you like this? Share it: