Skip to content

Instantly share code, notes, and snippets.

View ben-av's full-sized avatar

Ben Aviram ben-av

  • FlyMoney / AI21 Labs
View GitHub Profile
alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split("")
base = alphabet.length
exports.encode = (i) ->
return alphabet[0] if i is 0
s = ""
while i > 0
s += alphabet[i % base]
i = parseInt(i / base, 10)