Geekblok

B10m, BOK, Joffie - old geeks on a blog

Entries Comments



Storing data the fun way

27 December, 2007 (23:56) | fun, technical | By: B10m

cluster

Storing data is not a problem anymore. Google gives you a couple of gigabytes email storage for free, Yahoo! gives you “unlimited” email storage, a plethora of sites like YouSendIt and Files4Ever give you plenty of storage, and hooking up your own machine to the online world never has been easier with all the cheap ADSL/Cable connections we have nowadays. All good, but not fun. Therefor, let’s store text in a place people wouldn’t suspect (and probably don’t want).

Like the avalanche of file sharing websites mentioned before, another breed of website seems to be quite popular: the URL shorteners. TinyURL, is.gd, etc. etc. There are many and a lot of them don’t care what you feed them! (I bet you start seeing where I’m going with this post…)

Let’s look at is.gd. On their technical page, they say:

is.gd will shorten URLs up to 2,000 characters in length. This is an arbitrary limit we’ve imposed to limit misuse. We’ve never seen a valid URL approaching this length and hopefully never will.

Fair enough. I wouldn’t accept over 2000 characters as an URI (tinyurl let’s you store more. Finding the limit of that site, I’ll leave as an exercise to the reader). So let’s see if we can add some invalid URLs, but 2000 characters nonetheless. Lipsum.com to the rescue! The webservice allows 2000 characters, including the scheme (so choose ftp, it saves one character over http). So all we need to do, is to feed it an url like ‘ftp://’, followed by 1994 characters of choice.

Proudly, the site tells us:

We made your URL 99% (1985 characters) shorter!

Wonderful! But can we retrieve the data easily as well? Of course!

#!/usr/bin/perl

use strict;
use LWP::UserAgent;

my $ua  = LWP::UserAgent->new(
requests_redirectable => [ ]);
my $res = $ua->head('http://is.gd/iN');
print $res->header('Location') =~ m!ftp://(.*)!;

Et voila, our Lorem Ipsum data is back. Free online storage! Ok, only 1994 characters at a time (check out tinyurl, if you need a little more), but I bet `man split` will come in handy here too serpent smile. Seriously, I doubt the guys at is.gd will like your pumping your data in their databases, so do please use the alternatives mentioned before.

Write a comment





Preview: