Tuesday, March 10, 2009

The Aimless Surfing Google Gadget

I think this will be probably a multi-part series on this gadget and how I went about writing it.

Twittestract: A Google gadget that creates random url's and then provides a link to their destination. This should help people surf the web more aimlessly.

As I was completing my recent discussion of link shortening, I became curious about what would happen if you entered a random set of characters after the http://www.tinyurl.com/ url. Sure enough when I did that, I was sent to a random site. This gave me an idea for a Google Gadget. I need to create some Google gadgets anyway for work, so I thought this would be a great way to learn how to do them. The idea was to create a random string of characters between 1 and 5 characters in length and then redirect the user to that site. I was wondering how many times I would encounter a dead link when I stumbled upon this site about tinyurl whacking which answered a lot of my questions about how the strings are formed. The tinyurl whacking site was doing what I wanted the Google Gadget to do but manually. So, my idea wasn't original at all, but I am improving something. The author of that site cautioned that you never know what is on the other side of a link. After a few missteps of my own, I realized that you don't really want to be tinyurl whacking with your mom watching over your shoulder.

The gadget itself has two controls, a drop down list for the number of characters in the random string and a button to generate a new random string. TinyUrl allocated all of the one character strings and then the two character strings and is now populating 5 and 6 digit strings. Since there are 62 possible characters per place I think that means that TinyUrl is referencing over nine hundred million links. Hopefully, that is enough to give you a truly random experience.

So, as often happens with software, the Gadget got a little more complicated when I added the preview function. I now wanted to not only create the url for tinyurl but preview the url it points to out in the big wide Internet. Thankfully, someone has already done some work here as well, so using Embiggen and dissecting that to get to Dapper , I was able to utilize a web service that would grab the tinyurl preview link and let me display it. So, that's what I've done. If you are just interested in grabbing the Gadget and don't care about how I created it, you can grab it from the link below. A big warning, though. Big warning: there is some nasty/offensive/virus-laden content on the other side of tinyurl links sometimes. If a proposed link looks suspicious, then use the "Make Another" button to generate a new link. Here is the screenshot (I've also added the gadget itself to the sidebar for the time being).

This is a link to the "Add this Gadget to my Webpage" and one to "Add the Gadget to my iGoogle page"

If you're interested in how I created this or want to follow my progress of adding this gadget to the Google Directory, check back in a few days and I will explain the code and some of the issues I faced writing the gadget. This little toy aside, I think I have the basics down now for creating some useful Gadgets to use on my website or to distribute.

No comments:

Post a Comment