Skip to content

Instantly share code, notes, and snippets.

@starenka starenka/uuid.py
Created Nov 4, 2013

Embed
What would you like to do?
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
You can’t perform that action at this time.