Last active
December 31, 2015 14:12
-
-
Save bmacauley/5309589 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| def to_base(q, alphabet): | |
| if q < 0: raise ValueError, "must supply a positive integer" | |
| l = len(alphabet) | |
| converted = [] | |
| while q!= 0: | |
| q, r = divmod(q, l) | |
| converted.insert(0, alphabet[r]) | |
| return "".join(converted) or '0' | |
| to_base( hash(str(uuid.uuid1())) % 100000000, | |
| '0123456789abcdefghijklmnopqrstuvwxyz') ) | |
| to_36(q): | |
| return to_base(hash(str(uuid.uuid1())) % 100000000, '0123456789abcdefghijklmnopqrstuvwxyz') ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment