Created
March 11, 2009 23:24
-
-
Save cpinto/77812 to your computer and use it in GitHub Desktop.
Single line url shortener in python
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
# usage: gen_token(n) | |
# Pass this the numerical ID of an URL at the cross reference table | |
# and you'll get a tinyurl-like base36 string | |
gen_token=lambda n,cs="0123456789abcdefghijklmnopqrstuvwxyz":(lambda b=len(cs):cs[n%b]+gen_token((n-(n%b))/b))() if n else "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment