technoweenie/guillotine — Issue #3: Doesn't work on ruby 1.8.x
Author: technoweenie
Created: 2011-11-15 05:45:51+00:00
State: open

It has to do with the [url shorten code](https://github.com/technoweenie/guillotine/blob/master/lib/guillotine.rb#L44):

```
>> Digest::MD5.hexdigest(url).to_i(16)
=> 191415658344158766168031473277922803570
>> [Digest::MD5.hexdigest(url).to_i(16)].pack("N")
RangeError: bignum too big to convert into `unsigned long'
from (irb):6:in `pack'
```

The most common url shortening algorithms involve mapping a unique ID to some custom encoding:

> How to convert the id to a shortened URL:
>
> * Think of an alphabet you want to use. In your case that's [a-zA-Z0-9]. It contains 62 letters.
> * Take the auto-generated unique numerical key (auto-incremented id): for example 125 (a decimal number)
> * Now you have to convert the 125 (base 10) to X (base 62). This will then be {2}{1} (2×62+1=125).
> * Now map the symbols {2} and {1} to your alphabet. Say {0} = 'a', {25} = 'z' and so on. We will have {2} = 'c' and {1} = 'b'. So '/cb' will be your shortened URL.

http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener

Riak has no way to get this though. I have some thoughts on doing host-based counters, but it's way out of scope. Maybe if someone gets really bored...