Skip to content

Instantly share code, notes, and snippets.

@cwsaylor
Created November 3, 2009 17:18
Show Gist options
  • Save cwsaylor/225238 to your computer and use it in GitHub Desktop.
Save cwsaylor/225238 to your computer and use it in GitHub Desktop.
URL_CHARS = ('0'..'9').to_a + ('a'..'z').to_a + ('A'..'Z').to_a + ['-', '_'] - ['a', 'e', 'i', 'o', 'u'] - ['A', 'E', 'I', 'O', 'U']
URL_BASE = URL_CHARS.size
def generateUrl(idNumber)
localCount = idNumber
result = '';
while localCount != 0
rem = localCount % URL_BASE
localCount = (localCount - rem) / URL_BASE
result = URL_CHARS[rem] + result
end
return result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment