Saturday, 17 November 2012

How I started my own URL shortener, and why I wanted to

A few weeks ago, I decided to set up my own URL shortener. There were a few reasons why I decided to do this, the main one being "because I can". On a more sensible note, commercial URL shortening services occasionally shut down. A good example of this was Tr.im. Whilst other services like bit.ly probably won't go anywhere for a while, I'm uncomfortable leaving data that would take a lot of work to re-create (finding every Tweet, Facebook post, blog comment etc. that I'd ever posted a shortened URL in and editing it) in the hands of a third party. Even though in practise most shortened URLs have a fairly short useful life, leaving dead links lying around looks unprofessional.

I've been interested in growing my domain portfolio for a while, and had purchased a short domain, sm88.co.uk, a few weeks beforehand with the intention of using it as a small landing page with contact and social networking details since it would be easier to give out verbally than my main domain name. At 10 characters, it's at the top end of being a sensible length for a URL shortener, but since I'm wary of buying domains with foreign TLDs it's probably the closest I'll come to buying a short, memorable name. Therefore it made sense to use it.

Next, I needed to find a script to shorten URLs. Although several commercial URL shorteners will host a domain and perform shortening, using one would defeat the point as if the service went down so would my shortened links. I needed something that would run on my own shared hosting account. There are various pre-written PHP scripts floating around that looked like they would do the job, but after a bit of research the most polished and complete solution proved to be a script called Yourls.

The Yourls website has a simple tutorial on how to install and configure the script. Although part of the process involves editing a config file by hand, which isn't particularly user-friendly, the documentation is good enough that it isn't a problem. I had the whole thing up and running in about 20 minutes, including uploading the files.

By default, Yourls allows the short version of a URL to be specified manually. If a URL isn't specified, it generates it's own sequentially starting with 1. Somehow, a shortened URL with only one character (like sm88.co.uk/1) doesn't look quite right. A quick visit to the Yourls Plugin List turned up "Random Keywords", which changes the default behaviour to generating random keywords of a given length instead of sequential characters. This makes the generated URLs look more like URLs from other shortening services. Like Yourls itself, adding the plug-in required modifying a file by hand. This wasn't particularly difficult (and gave me a good excuse to play with some settings) but it would be off-putting to the average end user.

The procedure listed above creates a perfectly usable URL shortening service. There are still things I want to experiment with, like using a bookmarklet to generate URLs without logging into the admin interface and finding an iPhone app to do the same, but neither of these are particularly pressing as I'm confident that Yourls is extensible enough to do both. One of it's other advantages is that, whilst shortened URLs use the root of the domain, the actual root (sm88.co.uk/) isn't used. At present, this is simply redirected to my nameplate site. However, at some point in the future I can redirect it somewhere else and use the domain for the purpose I originally bought it for without upsetting my shortened URLs.

Sunday, 12 August 2012

Formatting source code on Blogger with SyntaxHighlighter

In my last post, I shared a few lines of Linux terminal commands. Apart from the <pre> HTML tag, which uses a monospaced font and preserves white space, Blogger doesn't provide an easy way to publish this type of data. In a post with a couple of lines of code, this is a minor inconvenience. However, I hope to be able to share longer code snippets at some point in the future, and without some form of syntax highlighting this would quickly become difficult to read.

Sunday, 5 August 2012

Persuading Ubuntu to recognise my Netgear WG121 Wireless Adapter

This is something I've been meaning to do for a while, but have never quite got around to. I'd even bought an extra, second hand adapter purely on the basis that it worked under Linux without any messing about. However, I had my hand forced this weekend when I discovered that the adapter I normally use had failed - presumably a severe hardware fault since neither Ubuntu's lsusb command or Windows XP's "Found New Hardware" wizard would recognise it. The process for getting the Netgear WG121 working should have been fairly straightforward, but unfortunately it wasn't. I decided to document it here in the hope that it might help someone else with the same problem.

Tuesday, 17 July 2012

Two Months with my Amazon Kindle Touch - A Review

It's two months to the day since I took delivery of my Amazon Kindle Touch, so I think it's time to write a review.

Sunday, 1 July 2012

How I integrated a Blogger blog into my website - and why I wanted to

I'm having a big overhaul of my online presence, in an attempt to make an impression on my search engine rankings. This might be a pipe dream since I share my name with several pretty influential people, but it can't hurt to try.

I've read lots of advice about personal brand management, and one of the key themes that keeps cropping up is that it's no longer enough to run one website targeting a particular keyword, it's also necessary to be active on the various big social networking websites and to try to get content published in other places. The most obvious way to do this seemed to be to start blogging.