I\'m thinking about using the encode/decode technique here (Encoding to base 36/decoding from base 36 is simple in Ruby)
how to implement a short url like urls in twitte
I wrote this baseXY shortener, designed for a very similar question/need I had:
https://github.com/marko-36/base29-shortener.
This is it, hope it helps:
const c=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '2', '3', '4', '5', '6', '7', '8', '9'];
//characters for encoding
function to29(i){
var sLen = Math.floor(Math.log(i)/Math.log(c.length)) +1;
var s = '';
for(ex=sLen-1; ex>-1; --ex){
s += c[Math.floor(i / Math.pow(c.length,ex))];
i = [i % Math.pow(c.length,ex)];
}
return s;
}
function from29(s){
var i = 0;
for (ex=0; ex