Posted: June 21st, 2008 @ 02:59am
No Comments »
I wrote this a while ago for a different domain name but didn’t register it in time. I found the code a few days ago and have just finished putting the finishing touches on it. Nothing special, just a URL shortener with a base length of just 14 characters and a minimum ID length of 1.
http://jmp.li/
For those who care… it’s written in PHP, uses MySQL for storage but the destinations are cached at runtime for efficiency.
Posted: June 18th, 2008 @ 11:09pm
No Comments »
If you’re using PHP you want PHPMailer. If you’re using something else there’s probably an equivalent library (Google is your friend). However, regardless of how you do it you should always consider the impact of your email activities on your users. Unwanted email is one of the biggest problems on the Internet today and the more you can do to present your website as a responsible sender of email the better.
Read the rest of this entry »
Posted: June 17th, 2008 @ 11:26am
Tags: 23x, hdr, jared earle, Photography | 2 Comments »
My mate Jared has posted a most excellent tutorial on High Dynamic Range (HDR) photography. I haven’t tried this yet but I definitely will the next time I’m out with my camera - nice work Jared!

HDR example by Jared Earle, used with permission
Posted: June 8th, 2008 @ 09:42pm
Tags: activerecord, PHP | No Comments »
I wanted an object-oriented way of accessing a database that strikes a good balance between abstracting the details of SQL escaping, insert or update, etc and going too far to the point where the benefits are drowned out by the abstraction. In this article I present the system I am currently using. It does most of what I wanted but certainly has potential for further improvement.
The main reason this post exists is due to a request from someone on the PHP-General list. This code is not intended to be bug-free or extensively tested or indeed anything. Treat it as you would any other experimental code. Read the rest of this entry »
Posted: June 8th, 2008 @ 09:13pm
Tags: javascript | No Comments »
Let me start by saying I hate pop-unders. They clutter up peoples desktops and generally annoy users. Unfortunately they are one of the most effective forms of web-based advertising at the moment, although I’m not sure why. I’ve had a few questions over recent months about how to implement pop-unders so here it is.
Pop-ups are easy, you just call the javascript function window.open with the required parameters. To turn a pop-up into a pop-under is simple. On the page that’s loaded in the pop-up, simply add the following snippet…
<script type="text/javascript">
self.blur();
</script>
That will cause the popped-up window to sink behind whatever opened it.
Note that I accept no responsibility for the complaints you’ll get from users if you start doing this. You’re on your own!
Posted: June 8th, 2008 @ 09:08pm
Tags: PHP | 2 Comments »
Are you seeing backslashes (\) being inserted before quotes in the data you’re using? Have you “solved” the problem using stripslashes? Do you want to know where these are coming from and how to stop it? Of course you do… read on!
Read the rest of this entry »
Posted: June 8th, 2008 @ 08:56pm
Tags: PHP | No Comments »
This is a very common situation. You’re taking input from the user, including their email address. You want to make sure that they’re not feeding you a load of crap, so you want to validate their email address. The best way to do this is with a regular expression, but it’s not a simple task.
Cal Henderson (of Flickr fame) wrote an excellent article a little while ago where he wrote a regular expression against the specification document that defines these things. As Cal points out, that specification is RFC822. Now this potentially has its problems because it was written in 1982 and the rules regarding valid characters in domain names have changed since then, but as far as I can tell his solution has then covered.
Check out his article: http://iamcal.com/publish/articles/php/parsing_email/
Hopefully Cal won’t mind if I reproduce the end result of his work here…
function is_valid_email_address($email)
{
$qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
$dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
$atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'.
'\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
$quoted_pair = '\\x5c[\\x00-\\x7f]';
$domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d";
$quoted_string = "\\x22($qtext|$quoted_pair)*\\x22";
$domain_ref = $atom;
$sub_domain = "($domain_ref|$domain_literal)";
$word = "($atom|$quoted_string)";
$domain = "$sub_domain(\\x2e$sub_domain)*";
$local_part = "$word(\\x2e$word)*";
$addr_spec = "$local_part\\x40$domain";
return preg_match("!^$addr_spec$!", $email) ? 1 : 0;
}
For a recent project I needed a function to just validate a domain name, so I extracted the relevant parts and created the following function…
function is_valid_domain($domainname)
{
$dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
$atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'.
'\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
$quoted_pair = '\\x5c[\\x00-\\x7f]';
$domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d";
$domain_ref = $atom;
$sub_domain = "($domain_ref|$domain_literal)";
$domain = "$sub_domain(\\x2e$sub_domain)*";
return preg_match("/^$domain$/i", $domainname) ? true : false;
}
Posted: June 2nd, 2008 @ 05:10pm
Tags: design | 1 Comment »
I’m loving this one. Content is king!!
Still a few bits that need sorting layout-wise (if the comment form below is the right width then I’ve done it!) but definitely a major improvement on the old new design.
I’ll shortly be migrating the articles into blog posts. I don’t think there’s a legitimate distinction to be made, and blog posts come bundled with comment and trackback abilities which is handy.
Posted: May 24th, 2008 @ 12:09am
Tags: downforeveryoneorjustme, istwitterdown, titsup, twitter | No Comments »
Ok, so Twitter is currently down. I know this because TitsUp.net told me so.
IsTwitterDown.com says it’s working.
DownForEveryoneOrJustMe.com is returning a 502 error itself so I don’t actually know if it can tell that Twitter’s not working.
So in short, use TitsUp.net - it’s better than the rest!!
Posted: May 23rd, 2008 @ 01:29pm
Tags: domain checker, titsup, url checker | 2 Comments »
I was a bit bored the other day but managed to find something to do. Something reminded me of a guy I used to work with who used the phrase “It’s all gone tits up” a lot. He headed up the test team so he had reason to use it!
I don’t really know why but I decided to log in to my Gandi account and checked the availability of titsup.*, found that titsup.net was available and registered it.
The result of all this is that I’ve developed a simple website to check if a given URL is working. There are other sites that do this, mainly in response to Twitter downtime, but in an effort to differentiate TitsUp from those it has two features I couldn’t find anywhere else.
It can check a domain name like the others, but you can also enter a complete URL and it will check that. It follows all redirects until it reaches a destination and it also lets you know exactly what went wrong rather than just saying whether it’s working or not.
The other feature is only evident if the URL you check is not working. TitsUp will offer to check a failing URL every 10 minutes for the next 24 hours. If it starts working you’ll get an email telling you the good news. If it’s still not working after 24 hours you’ll get an email saying so. It can also optionally notify you in both cases via a direct message in Twitter thereby allowing you to get an SMS notification as well as an email. Note that for this to work you’ll need to follow the titsup user.
As a simple tool I think it works really well. I’m interested in any opinions people might have so please let me know what you think. Now all I need to do is create an icon for the site and Twitter user. Anyone fancy giving that a go?