Category ArchiveCode
Code Adam Deacon on 06 Aug 2008
Wordpress style permalinks
Recently I was writing a database driven website, where all the content was within a database and the only real page was index.php.
This is easy enough to do, but of course, you need to tell index.php which page you want so you end up with URL like http://www.deaconsworld.org.uk/index.php?PageID=12 or http://www.deaconsworld.org.uk/index.php?PageID=36. Not the most user or SEO friendly. What I really wanted was URL that looked like this: http://www.deaconsworld.org.uk/contact/ or http://www.deaconsworld.org.uk/about/
Code Adam Deacon on 23 Apr 2007
Changing the load order of a webpage
I had an exciting weekend of writing a wonderful ‘webcast’ system. Although it worked fine over the LAN, I found I had a problem when I uploaded it to the internet. The problem as a little weird. The system work by loading a bunch of images then used a version of 1pixelout’s mp3 flash player to play the audio. The problem I had was that half the images were loading, then the flash started loading. A user would then have to wait until the mp3 had finished playing before the final images were loaded.
I searched high and low on the net to see if there was a magical way to control the loading order. In the end I found this really elegant solution to load the flash as the last item.
In your style sheet, give the style you want to appear last: display: none;Then in the body tag change the display to block using onload:document.getElementById('audio').style.display = 'block';"
I’ve tested this in Firefox and IE on both Linux and Windows and it seem to work perfectly.
Code & Linux Adam Deacon on 17 Apr 2007
Lovely test data
I’ve spent most of my weekend thinking up names. Am I having a baby? NO! Do I need a killa handle for my next l33t project? No. Am I thinking of running away and setting up a new life for my self living in a tree? Yes, but that not why.
The reason I’ve been thinking up new names is I’ve been testing my latest, greatest app and needed to fill it with test data. I hate thinking of test names. Normally I end up with bob, bob1, bob2 or my favourite piece of test data “rich is gay”. That’s fine if you just want a few test name, but what if you want say 1000 or 2000 or 10,000. That were Benjamin Keen’s Data Generator comes in. It’s a little script that create random data perfect for shoehorning in to any app you want. It will even output CSV, MySQL, XML, Excel or HTML and best of all it’s GNU
I’ve put a copy at http://www.deaconsworld.org.uk/datagenerator/ to try and save him some bandwidth.
Code Adam Deacon on 26 Feb 2007
Converting Unix time to Time stamps
I’ve been busy with a lot of time dependant code this week and working in Unix Time (number of seconds since epoch) has been making my brain go a bit squishy. Here a nice little code snippet for converting unixtime to a proper timestamp
perl -e 'print scalar localtime($ARGV[0]),"\n"' [unixtime] so: perl -e 'print scalar localtime($ARGV[0]),"\n"' 1172160024
Thu Feb 22 16:00:24 2007
If you use this a lot, there’s nothing to stop you putting this in a nice little script, such as:
#!/bin/perl
print scalar localtime($ARGV[0]),"\n"