A URL shortener written in ten minutes

Friday night, or more specifically, Friday February 26th 2016 at 19:45:57, I was having a group Skype call with Alexander CraggsMiles Budden and Tom Emmerson when Alexander started complaining that all the URL shorteners out there were becoming too long. To clarify, URL shorteners were becoming bloated. He suddenly said, “Let’s make a URL shortener”. The situation escalated very rapidly and within 5 minutes, Miles had bought the domain subr.pw for an astronomical price of £0.60, I had setup Nginx on the server used for the majority of SubjectRefresh‘s projects and Alexander had setup the codebase and had a Node.js skeleton ready to go.

We went with subr.pw for two reasons. The first was that our project was a URL shortener, which meant the URLs needed to be short and that domain was only six characters long. Secondly, it didn’t obfuscate our brand, SubjectRefresh too much – which was a major point for us.

We then found a package on NPM called Short and started to implement it. In the next 20 minutes, the DNS had propagated and we had an alpha version of our project up and running. We were pretty astounded for we had never created a fully working project in under an hour before. In fact, we were so pumped that we decided to keep working on it until it was working perfectly. As can be seen from our commits, we were hindered ever so slightly by Tom insisting that Python couldn’t be left out.

Screen Shot 2016-02-27 at 19.03.27.png

I went to find some pizza but when I returned, I discovered to my dismay that Alexander and Miles had started playing Counter Strike and were in no fit state to program, or hold a real conversation.

Never mind! I took up the baton and wrote in some other things, such as a nice UI and much better error handling and tolerance. The UI was actually taken from a Codepen mainly because we felt that using a front-end framework was overkill, meaning custom design was the only way to go. Due to the fact that the three of us working on the project at the time were primarily back-end developers and only use frameworks for front-end, it was deemed that we might as well use a pre-built page.

The next day, Saturday, we were still on such a high that Alexander and I decided that we needed to write our own library for the URL shortener. The main reason for this was we wanted to be able to access in-depth analytics about what it was being used for. So, during that day, Alexander with support from me in the form of insisting on semicolons and commit standards, wrote our own entire URL shortener library, complete with randomly generated keys and paste-to-generate! The new system is built using MongoDB to store all the data and again uses Socket.IO for the communication. It even stops duplicate URLs being stored in our database to save space and time. This allows us to track analytics of specific URLs much more easily and more efficiently if there aren’t lots of duplicates in the system.

Alexander has also written a blog post about our Shortener hackathon, which is available at http://popey456963.github.io/blog/archive/setting-up-a-url-shortener.

You can start shortening your URLs over at subr.pw now!

 

3 thoughts on “A URL shortener written in ten minutes

  1. Hi would you mind letting me know which webhost you’re utilizing?
    I’ve loaded your blog in 3 different browsers and I must say this blog loads a lot quicker
    then most. Can you suggest a good internet hosting provider at a honest price?

    Many thanks, I appreciate it!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s