Popular recipes by Garel Alex http://code.activestate.com/recipes/users/2757636/2013-10-15T07:30:39-07:00ActiveState Code RecipesGet a value un windows registry (Python) 2013-10-15T07:30:39-07:00Garel Alexhttp://code.activestate.com/recipes/users/2757636/http://code.activestate.com/recipes/578689-get-a-value-un-windows-registry/ <p style="color: grey"> Python recipe 578689 by <a href="/recipes/users/2757636/">Garel Alex</a> (<a href="/recipes/tags/registry/">registry</a>, <a href="/recipes/tags/win32api/">win32api</a>, <a href="/recipes/tags/windows/">windows</a>). </p> <p>A small function to get a value in windows registry from its key path and value name.</p> <p>Note that recipe <a href="http://code.activestate.com/recipes/502268/" rel="nofollow">http://code.activestate.com/recipes/502268/</a> gives a more complete solution.</p> Safe HTML string and unicode (Python) 2012-01-10T08:14:14-08:00Garel Alexhttp://code.activestate.com/recipes/users/2757636/http://code.activestate.com/recipes/578008-safe-html-string-and-unicode/ <p style="color: grey"> Python recipe 578008 by <a href="/recipes/users/2757636/">Garel Alex</a> (<a href="/recipes/tags/html/">html</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/web/">web</a>). Revision 2. </p> <p>As you display message on a web page, you have to sanitize input data coming from users to avoid <a href="https://en.wikipedia.org/wiki/Cross-site_scripting">XSS</a>. Here is a small recipe where we can use a special class for our string to be sure we get safe all the way long.</p> Find a unique name based on prefix + digit in log2(n) + log2(n/2) (Python) 2011-10-31T20:30:54-07:00Garel Alexhttp://code.activestate.com/recipes/users/2757636/http://code.activestate.com/recipes/577934-find-a-unique-name-based-on-prefix-digit-in-log2n-/ <p style="color: grey"> Python recipe 577934 by <a href="/recipes/users/2757636/">Garel Alex</a> (<a href="/recipes/tags/name/">name</a>, <a href="/recipes/tags/unique/">unique</a>). </p> <p>Find a unique name based on a prefix for a content in a container (eg. a file in a directory) adding a digit to the name</p> <p>Does it in log2(n) + log2(n/2) were n is the number of duplicates</p> <p>This would be used eg. in a CMS giving identifiers based on content title, or when shortening file names on a file system, etc.</p>