Skip to content

Instantly share code, notes, and snippets.

@hungryblank
Last active December 12, 2015 03:28
Show Gist options
  • Save hungryblank/4707085 to your computer and use it in GitHub Desktop.
Save hungryblank/4707085 to your computer and use it in GitHub Desktop.
class Base62
CHARS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
SIZE = CHARS.size
def self.short(number)
return 0 if number == 0
chars = ''
while number != 0 do
number, mod = number.divmod(SIZE)
chars << CHARS[mod]
end
chars.reverse
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment