Skip to content

Instantly share code, notes, and snippets.

@mattupstate
Created December 10, 2014 21:29
Show Gist options
  • Select an option

  • Save mattupstate/a6dd35ec335b426eae55 to your computer and use it in GitHub Desktop.

Select an option

Save mattupstate/a6dd35ec335b426eae55 to your computer and use it in GitHub Desktop.

Revisions

  1. Matt Wright created this gist Dec 10, 2014.
    14 changes: 14 additions & 0 deletions url62.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    import string
    import uuid

    alphabet = string.digits + string.ascii_letters

    def base62_encode(n):
    ret = ''
    while n > 0:
    ret = alphabet[n % 62] + ret
    n /= 62
    return ret

    def url62():
    return base62_encode(uuid.uuid4().int)