This is probably absolutely boring and irrelevant to 99% 100% of my readers, but I’m gonna write about it anyway. If only just for my own records.
While writing my links directory for Food4Geeks, I had an idea: I wanted the script to automatically/dynamically generate a short URL (using http://is.gd), every time someone views the detailed description of a link.
The code looked a little like this:
include 'inc/shorten.php'; $url = $siteurl.'resources/details/'.$resource_id; $url = ShortUrl::create($url,'isgd');
So at the end, $url contained a working short URL for the record. Makes it easier to share on twitter and what not. But I descovered, that every time this is done, the site takes almost a second longer to load. I hate that kind of thing.
So I thought about a way to stop that. And I came up with a way. In the future, when I’ve written an admin area for the script, those URL will be generated when I insert new resources into the database. But for now (and as a failsafe), I’ve gone another way:
I’ve added a column to my resources table called ‘shorturl’. Every time someone clicks a resource (to see link details, description), the script checks if the resource in question has a short URL or not. If does, it fetches the short URL from my database and displays it to the user.
Result: loading time stays normal, no delays = Paul happy.
If it finds that no short URL is stored for that particular resource, it runs the above code and creates one. It then stores that new short URL.
Result: The first time that anyone ever clicks on the resource, the 1 second delay takes place. Because the short URL is created. But once that is done, there’s no more delays. Because then the short URL is stored in the database and all is well = Paul happy.
And the best part is: every time I insert a resource into the database, I check it myself anyway. So I’m the one that is the first to click it. So I get the 1 second delay. But nobody else will!
So yeah, this is a really cool little thing for me.

RSS Feed
Twitter

Ok, so being the curious bugger that I am, I decided to give KDE a go. Ubuntu comes with GNOME by default (I think), so I 


Ok, I couldn’t think of a better title – sorry.
Ladies and gentlemen, today is an exciting day!
One or two of my readers are aware that I run a seperate blog (in German) on paulvoth.net. I’ve been thinking about somehow combining it with this blog. I like things to be connected.