Skip to content

Instantly share code, notes, and snippets.

@starenka
Created November 4, 2013 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save starenka/7300267 to your computer and use it in GitHub Desktop.
Save starenka/7300267 to your computer and use it in GitHub Desktop.
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