Created
November 4, 2013 09:38
-
-
Save starenka/7300267 to your computer and use it in GitHub Desktop.
This file contains 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
class Document(models.Model) | |
def get_uuid(self): | |
def bijective_encode(i, start=0): | |
#http://stackoverflow.com/a/742047/754305 | |
i += start | |
CHARS = list('zpYUgh9XWvHbNVK6kmAufqCSeyiBZ7RcLd4GJ5ETMnwPDrx3s8QaF2jt') #randomized to avoid iteration | |
s = '' | |
base = len(CHARS) | |
while i > 0: | |
s += CHARS[i % base] | |
i /= base | |
return s[::-1] | |
return bijective_encode(self.id, start=int(1e5)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment