Popular recipes by denis http://code.activestate.com/recipes/users/4168005/2009-08-05T09:14:02-07:00ActiveState Code Recipesport-alldeps: list all dependencies of Macports packages (Python) 2009-08-05T09:14:02-07:00denishttp://code.activestate.com/recipes/users/4168005/http://code.activestate.com/recipes/576868-port-alldeps-list-all-dependencies-of-macports-pac/ <p style="color: grey"> Python recipe 576868 by <a href="/recipes/users/4168005/">denis</a> (<a href="/recipes/tags/macports/">macports</a>, <a href="/recipes/tags/package_dependency_graph/">package_dependency_graph</a>). Revision 2. </p> <p>port-alldeps package ... <br /> lists all dependencies of Macports packages -- 1st 2nd 3rd level ... <br /> by repeatedly calling "port deps".</p> bier-soup.py, a small example of BeautifulSoup (Python) 2009-07-24T05:59:43-07:00denishttp://code.activestate.com/recipes/users/4168005/http://code.activestate.com/recipes/576841-bier-souppy-a-small-example-of-beautifulsoup/ <p style="color: grey"> Python recipe 576841 by <a href="/recipes/users/4168005/">denis</a> (<a href="/recipes/tags/beautifulsoup/">beautifulsoup</a>, <a href="/recipes/tags/bier/">bier</a>). Revision 3. </p> <p>bier-soup.py reads html tables like those in <a href="http://www.bier1.de" rel="nofollow">http://www.bier1.de</a> and writes plain text files, as a small example of BeautifulSoup</p> Walker's alias method for random objects with different probablities (Python) 2008-11-16T15:05:51-08:00denishttp://code.activestate.com/recipes/users/4168005/http://code.activestate.com/recipes/576564-walkers-alias-method-for-random-objects-with-diffe/ <p style="color: grey"> Python recipe 576564 by <a href="/recipes/users/4168005/">denis</a> (<a href="/recipes/tags/random_number/">random_number</a>, <a href="/recipes/tags/walker_s_alias/">walker_s_alias</a>). </p> <p>an example, strings A B C or D with probabilities .1 .2 .3 .4 --</p> <pre class="prettyprint"><code>abcd = dict( A=1, D=4, C=3, B=2 ) # keys can be any immutables: 2d points, colors, atoms ... wrand = Walkerrandom( abcd.values(), abcd.keys() ) wrand.random() # each call -&gt; "A" "B" "C" or "D" # fast: 1 randint(), 1 uniform(), table lookup </code></pre> uniform matcher( "re pattern" / re / func / dict / list / tuple / set ) (Python) 2009-05-06T06:17:16-07:00denishttp://code.activestate.com/recipes/users/4168005/http://code.activestate.com/recipes/576741-uniform-matcher-re-pattern-re-func-dict-list-tuple/ <p style="color: grey"> Python recipe 576741 by <a href="/recipes/users/4168005/">denis</a> (<a href="/recipes/tags/grep/">grep</a>, <a href="/recipes/tags/re/">re</a>, <a href="/recipes/tags/text_processing/">text_processing</a>, <a href="/recipes/tags/uniform/">uniform</a>). Revision 2. </p> <p>matcher() makes a string matcher function from any of:</p> <ul> <li>"RE pattern string"</li> <li>re.compile()</li> <li>a function, i.e. callable</li> <li>a dict / list / tuple / set / container</li> </ul> <p>This uniformity is simple, useful, a Good Thing.</p> <p>A few example functions using matchers are here too: grep getfields kwgrep.</p> openplus(): open pipes, urls ... uniformly with Popen, urlopen ... open (Python) 2008-12-11T05:40:15-08:00denishttp://code.activestate.com/recipes/users/4168005/http://code.activestate.com/recipes/576582-openplus-open-pipes-urls-uniformly-with-popen-urlo/ <p style="color: grey"> Python recipe 576582 by <a href="/recipes/users/4168005/">denis</a> (<a href="/recipes/tags/file/">file</a>). Revision 3. </p> <p>openplus() opens pipes and some other objects that quack like files, as well as files:</p> <pre class="prettyprint"><code>| pipe ... -- Popen() a shell <a href="http://" rel="nofollow">http://</a> ftp:// ... -- urlopen() `ls $x`, `geturl web data` -- shell -&gt; filename or url ~/a/b -- sh ls .gz -- gunzip - -- stdin / stdout else -- the builtin open() </code></pre> <p>Users can then read e.g. "| filter data | sort" "| convert ... xx.jpg" "`geturl web data`" like files, just by importing openplus and changing open() -> openplus().</p>