def base62_encode(num):
num = int(num)<EOL>alphabet = '<STR_LIT>'<EOL>if (num == <NUM_LIT:0>):<EOL><INDENT>return alphabet[<NUM_LIT:0>]<EOL><DEDENT>arr = []<EOL>base = len(alphabet)<EOL>while num:<EOL><INDENT>rem = num % base<EOL>num = num // base<EOL>arr.append(alphabet[rem])<EOL><DEDENT>arr.reverse()<EOL>return '<STR_LIT>'.join(arr)<EOL>
Encode a number in Base X. WIth the built-in alphabet, its base 62

    `num`: The number to encode
    `alphabet`: The alphabet to use for encoding
    Stolen from: http://stackoverflow.com/a/1119769/1144479