Popular recipes by Mark Zitnik http://code.activestate.com/recipes/users/4166559/2008-09-21T07:22:06-07:00ActiveState Code RecipesCreating beautiful urls from user generated text (Python) 2008-09-21T07:22:06-07:00Mark Zitnikhttp://code.activestate.com/recipes/users/4166559/http://code.activestate.com/recipes/576511-creating-beautiful-urls-from-user-generated-text/ <p style="color: grey"> Python recipe 576511 by <a href="/recipes/users/4166559/">Mark Zitnik</a> (<a href="/recipes/tags/beautiful/">beautiful</a>, <a href="/recipes/tags/url/">url</a>, <a href="/recipes/tags/web/">web</a>). Revision 3. </p> <p>Most of the web sites that work with user generated content use the text that was entered by the user as the url for this specific item and usually the user enter charates like ' '(space) '&amp;', '.' and some other char that you want to remove or convert to _ , _and_ , _dot_. So i have wrote a dynamic code that you can setup what chars you what to change.</p> Base Conversion decimal to base = len(map) (Python) 2008-08-20T05:01:39-07:00Mark Zitnikhttp://code.activestate.com/recipes/users/4166559/http://code.activestate.com/recipes/576435-base-conversion-decimal-to-base-lenmap/ <p style="color: grey"> Python recipe 576435 by <a href="/recipes/users/4166559/">Mark Zitnik</a> (<a href="/recipes/tags/base/">base</a>, <a href="/recipes/tags/conversion/">conversion</a>, <a href="/recipes/tags/decimal/">decimal</a>, <a href="/recipes/tags/sequence/">sequence</a>, <a href="/recipes/tags/web_site/">web_site</a>). Revision 7. </p> <p>This code enable decimal base conversion according map length and a different char set.</p> <p>Example:</p> <ul> <li>map = ['0','1'] base 2 10 -> 1010</li> <li>map = ['a','b'] base 2 10 -> baba</li> <li>map = ['a','b','c','d','e','f','g','h','i','j','k','l'] base 12 10 -> k</li> <li>map = ['a','b','c','d','e','f','g','h','i','j','k','l'] base 12 100 -> ie</li> </ul> <p>this simple method can be used in web sites to hide a well known decimal sequence like user ids.</p>