History of the Idea
I was reading my twitter feed the other day and I saw that someone I follow uses a vanity domain to create the tiny URLs they share with their followers. This individual happens to be famous and thus likely has a marketing firm to do this for them, but it gave me an idea.
Also, in the last year or so I have come to the conclusion that it is more cost effective for me as an individual to use cloud-services rather than owning and maintaining my owner servers for personal use. This decision came from a number of factors: I moved and was forced to switch ISPs and the cost of a static-ip increased while overall service quality degraded (thanks Comcast), my existing server was becoming aged and needed some upgrades, and I started a new job leaving me with precious little time for personal projects and so the last thing I want to do is use that time maintaining yet another sever. While I still own a personal NAS for files I wish to retain control of as well as local caching, I don't generally run a home server for web-connected applications and even my NAS uses PoE and is powered down most of the time. This blog is hosted using a combinatoin of AWS Route53, Cloudfront and S3.
So, I began thinking about how I would create a tiny-url service without having a webserver in place to parse the URI and return a 301/302, without having a traditional database to maintain the translation from tiny to long url. As I mulled this over, several strategies came to mind and I began to write a tool that would create, list, remove and validate the URLs for me.
And thus, Stiny (GitHub link) was born.
Stiny allows you to leverage your preference of a number of cloud services to accomplish the task. Given that I run this domain using a static object store, that was my initial thought and from there my ideas went further afield.
Here is a link (literally a link I just happen to have open): http://docs.getpelican.com/en/3.3.0/getting_started.html
Here is an equivalent tiny link under my own vanity domain: http://epf.li/gAPi
Usage as a Binary
Here is the TL;DR of how to use the CLI:
% stiny --help Stiny - TinyURLs for Static Storage Usage: stiny new (<url>) [<name>] [--config=<config>] stiny validate (<url>) (<name>) [--config=<config>] stiny rm (<name>) [--config=<config>] stiny list [--config=<config>] stiny configure [--config=<config>] [--read] Options: -h --help Show this screen. -c --config=<config> Path to configuration file [Default: ~/.stiny/stiny.cfg] -r --read Show the contents of the config
This section covers the main configuration of the CLI, see Mechanisms and Storage
Creating Tiny URLs
Creating tiny URLs is more or less as easy as pasting them into a terminal and if you're like me you have a terminal open all day anyway:
% stiny new "http://www.elif.us/2014/08/stiny" Tiny link http://epf.li/vX2w to http://www.elif.us/2014/08/stiny created.
You can also specity the name of the tiny-text if you prefer:
% stiny new "http://www.elif.us/2014/08/stiny" stiny Tiny link http://epf.li/stiny to http://www.elif.us/2014/08/stiny created.
While not exactly a nice thing to do to your consumers, I wanted the ability to delete a link on the fly if for some reason I don't want it used anymore.
% stiny rm vX2w Tiny link http://epf.li/vX2w deleted.
Validating an Existing Link
And because I needed to implement validation for internal reasons anyway, I decided to expose it in the binary. The following command will ensure a link is going where you beleive it to be going:
% stiny validate "http://www.elif.us/2014/08/stiny" stiny Tiny link http://epf.li/stiny is valid. % stiny validate "http://www.elif.us/2014/08/NOT_STINY" stiny Tiny link http://epf.li/stiny is NOT valid.
Listing your TinyURLs
Within the first few hours of beginning to share links using this product, I realized that while short alphanumeric random strings are not easy to use. Therefore I wanted to ability to review the links currently in the data store:
% stiny list Create Date Tiny URL Long URL -------------------------- ------------------------- ---------------------------------------------------- Mon, 04 Aug 2014 07:02:28 http://epf.li/tMUI1 http://datascopeanalytics.com/what-we-think/2014/07 Tue, 05 Aug 2014 06:13:07 http://epf.li/zlbJz http://ryandlane.com/blog/2014/08/04/moving-away-f Thu, 07 Aug 2014 21:50:56 http://epf.li/4kbEV https://onlycoin.com/ Mon, 11 Aug 2014 16:48:56 http://epf.li/2ZI3L http://www.clevelandclinicmeded.com/medicalpubs/