Scary Docs

Google Docs errorPlacing your documents online, does require trust in the online service you choose to use. I usually have a pretty solid trust in google. They do however from time to time have some glitches. After getting the message in the screenshot for an hour, I did start to get the chills, as the document as long and didn’t exist anywhere else. After an hour or so, it did however reappear. phew.

Should you use sql specific statements?

It seems there are two camps when it comes to SQL and how to do database optimizations – the “generic camp” and “the specialist camp”. While I don’t consider myself an extremist, I am absolutely in the specialist camp and this little post is an explanation of why.

SQL is a generic database langauge . There are a few different standards in use (the language has progressed over time), but the core of the SQL language is pretty much the standard in most databases. It’s probably also standard – in any database – that the SQL standard has been extended with database-specific extensions which provides optimizations, functions or other options not available in the SQL standard.

Using these database-specific extensions while developing your application ties your application/website to the specific database, and if you need to switch database at some point, your need to rewrite your applications SQL statements, so they aren’t tied to that specific database.

While this may be true I haven’t once during my ten years of web development, once had to switch database either during development nor during operations. I’m sure it happens in some cases, but I’m also sure that those cases are pretty rare, and if you need to go over your application and change the SQL statements, spending time on that is probably one of the easiest parts of a “technology switch” (ie. switching from Mysql to an Oracle cluster).

In most cases, using and utilizing database specific extensions can provide you with some easy optimizations and boost the performance significantly. While you probably can avoid using them, you’ll probably need to move the functions into you application or make more complex database queries. Optimization is usually an evolution, not a revolution. If your performance isn’t as expected, the first step is usually where are the bottlenecks, where can we optimize the current state of things – not switching database, not switching programming language.

Before you become a SQL purist, do make a calculated guess on what the “database switch probability” is. In most cases it’ll probably be less than 1%, and if this is the case, all common sense should tell you to use the tool available to the best of your ability, right?


I just discovered O’Reilly CodeZoo today. What a cool idea – ”Find good code, use it quickly”. The net is just littered with bad code samples and finding a place where a high quality standard is set might be a great idea. Only problem is that the (probably) two most used languages on the net – PHP and Perl – aren’t allowed in (so far). Too bad, while good Perl code can be found, it’s hardly impossible to find any quality PHP code samples anywhere.

IP address conversion with Perl

With Perl you can do many interesting transformations of IP-numbers. Below is two small examples allowing conversions from “IP quad” (
format to a single decimal and back. The decimal format may be more convenient and efficient to store in a database.

  sub ip2dec ($) {
    return unpack N => pack CCCC => split /\./ => shift;

  sub dec2ip ($) {
    return join '.' => map { ($_[0] >> 8*(3-$_)) % 256 } 0 .. 3;

In CPAN you can find many modules aimed at using and manipulating IP-addressees.

Some include Net::IP and IP::Country.

Gmail filter feature wanted

I’ve been moving a fairly large part of my private mail to my Gmail account.  Gmail do have some amazing features for searching, labeling and handling mail and the virtually unlimited storage is also pretty cool – Much cooler than keeping a huge mail-archive on an IMAP-server or having it on a local fragile hard disk.

One of the more recent things I’ve started using GMail for is backups of this site. With the wp-db-backup plugin for WordPress a backup of the entired database is mail to my gmail account every 24 hours and using filters I’m applying a ”backup”-label and auto-archiving it (and avoiding noise in inbox).

While this works great, I’d like to be able to through a filter automatically delete messages older than say 7 days with a certain label. This could help me remove old backups automatically – and also clear-out mailing list messages (they usually have an online archive, so why waste Gmail space on a copy).

Date-based searching is already available in gmail, so please, someone at the Gmail development staff, make it available in filters too…