Popular recipes tagged "meta:loc=5"http://code.activestate.com/recipes/tags/meta:loc=5/2014-11-07T13:03:18-08:00ActiveState Code RecipesProxying WCF service (XML) 2014-11-07T13:03:18-08:00Tomáš Rampashttp://code.activestate.com/recipes/users/4179816/http://code.activestate.com/recipes/578958-proxying-wcf-service/ <p style="color: grey"> XML recipe 578958 by <a href="/recipes/users/4179816/">Tomáš Rampas</a> (<a href="/recipes/tags/dotnet/">dotnet</a>, <a href="/recipes/tags/fiddler/">fiddler</a>, <a href="/recipes/tags/wcf/">wcf</a>). </p> <p>Sometimes capturing WCF service communication e.g. with Fiddler is necessary. Following is the part of WCF service application config proxying WCF to localhost:8888</p> And yet another round-robin generator (Python) 2013-11-13T19:30:29-08:00Jan Müllerhttp://code.activestate.com/recipes/users/4183984/http://code.activestate.com/recipes/578768-and-yet-another-round-robin-generator/ <p style="color: grey"> Python recipe 578768 by <a href="/recipes/users/4183984/">Jan Müller</a> (<a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/itertools/">itertools</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/roundrobin/">roundrobin</a>). </p> <p>I know that there is a <a href="http://code.activestate.com/recipes/528936-roundrobin-generator/">nice recipe</a> already that even made it into the <a href="http://docs.python.org/2/library/itertools.html">Python documentation</a>, but this one is more concise and at the same time simpler.</p> <pre class="prettyprint"><code>&gt;&gt;&gt; list(roundrobin('ABC', 'D', 'EF')) ['A', 'D', 'E', 'B', 'F', 'C'] </code></pre> Get external IP (Bash) 2013-07-01T05:50:43-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578578-get-external-ip/ <p style="color: grey"> Bash recipe 578578 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/ipv4/">ipv4</a>). Revision 3. </p> <p>Checks IPv4</p> get all possible combinations of characters given a string (Python) 2011-08-15T04:15:42-07:00Yanghttp://code.activestate.com/recipes/users/4178968/http://code.activestate.com/recipes/577842-get-all-possible-combinations-of-characters-given-/ <p style="color: grey"> Python recipe 577842 by <a href="/recipes/users/4178968/">Yang</a> (<a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/permutation/">permutation</a>, <a href="/recipes/tags/string/">string</a>). </p> <p>This will give a result that is more than a permutation, but all possible combinations. An example is when input is 'abc', the output would be: a,ab,abc,ac,acb,b,ba,bac,bc,bca,c,ca,cab,cb,cba</p> quick 3-column grid CSS (CSS) 2010-09-15T17:13:26-07:00Trent Mickhttp://code.activestate.com/recipes/users/4173505/http://code.activestate.com/recipes/577391-quick-3-column-grid-css/ <p style="color: grey"> CSS recipe 577391 by <a href="/recipes/users/4173505/">Trent Mick</a> (<a href="/recipes/tags/column/">column</a>, <a href="/recipes/tags/grid/">grid</a>, <a href="/recipes/tags/layout/">layout</a>). </p> <p>CSS snippet for a 3-column grid. Based on that used for some Apple product pages.</p> <p>HTML:</p> <pre class="prettyprint"><code>&lt;div class="grid3col"&gt; &lt;div class="column first"&gt; ... &lt;/div&gt; &lt;div class="column"&gt; ... &lt;/div&gt; &lt;div class="column last"&gt; ... &lt;/div&gt; &lt;/div&gt; </code></pre> <p>In general, you have to recalculate the widths based on (a) the available full width in your pages and (b) the amount a spacing you want between columns.</p> Scramble a string of words, preserving spaces (Python) 2010-06-25T20:44:04-07:00Kai Malleahttp://code.activestate.com/recipes/users/4174276/http://code.activestate.com/recipes/577275-scramble-a-string-of-words-preserving-spaces/ <p style="color: grey"> Python recipe 577275 by <a href="/recipes/users/4174276/">Kai Mallea</a> (<a href="/recipes/tags/scramble/">scramble</a>, <a href="/recipes/tags/string/">string</a>, <a href="/recipes/tags/words/">words</a>). </p> <p>The following function will scramble a string, preserving spaces that separate the words, and return the result. I used this for a word game that scrambled words and phrases, which a player then attempted to descramble. For example, scrambling the following string: "teenage mutant ninja turtles" would return "etegnae tamtnu jnnai urtltes"</p> Parse HTTP date-time string (Python) 2010-01-20T13:47:50-08:00Sridhar Ratnakumarhttp://code.activestate.com/recipes/users/4169511/http://code.activestate.com/recipes/577015-parse-http-date-time-string/ <p style="color: grey"> Python recipe 577015 by <a href="/recipes/users/4169511/">Sridhar Ratnakumar</a> (<a href="/recipes/tags/datetime/">datetime</a>, <a href="/recipes/tags/http/">http</a>, <a href="/recipes/tags/parsing/">parsing</a>). </p> <p>This recipe will help you parse datetime strings returned by HTTP servers following the RFC 2616 standard (which <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3">supports three datetime formats</a>). Credit for this recipe goes to <a href="http://stackoverflow.com/questions/1471987/how-do-i-parse-an-http-date-string-in-python/1472336#1472336">ΤΖΩΤΖΙΟΥ</a>.</p> Convert Dictionary to XML (Python) 2009-10-28T10:39:44-07:00Adam M Prosthttp://code.activestate.com/recipes/users/4172124/http://code.activestate.com/recipes/576939-convert-dictionary-to-xml/ <p style="color: grey"> Python recipe 576939 by <a href="/recipes/users/4172124/">Adam M Prost</a> (<a href="/recipes/tags/convert/">convert</a>, <a href="/recipes/tags/dict/">dict</a>, <a href="/recipes/tags/dictionary/">dictionary</a>, <a href="/recipes/tags/simple/">simple</a>, <a href="/recipes/tags/xml/">xml</a>). </p> <p>A simple four line function for converting a dictionary into a simple xml string.</p> getcwd (C) 2009-07-23T20:01:42-07:00J Yhttp://code.activestate.com/recipes/users/4170398/http://code.activestate.com/recipes/576855-getcwd/ <p style="color: grey"> C recipe 576855 by <a href="/recipes/users/4170398/">J Y</a> (<a href="/recipes/tags/getcwd/">getcwd</a>). </p> <p>getcwd</p> Homogeneous list (Python) 2009-04-14T12:09:19-07:00marlonamorhttp://code.activestate.com/recipes/users/4169863/http://code.activestate.com/recipes/576718-homogeneous-list/ <p style="color: grey"> Python recipe 576718 by <a href="/recipes/users/4169863/">marlonamor</a> (<a href="/recipes/tags/list/">list</a>, <a href="/recipes/tags/type/">type</a>). </p> <p>This is a little code for making a list that can have only items from a list of types</p> Rot13 Quine (Python) 2009-04-22T10:05:34-07:00Daniel Lepagehttp://code.activestate.com/recipes/users/4160089/http://code.activestate.com/recipes/576724-rot13-quine/ <p style="color: grey"> Python recipe 576724 by <a href="/recipes/users/4160089/">Daniel Lepage</a> (<a href="/recipes/tags/encode/">encode</a>, <a href="/recipes/tags/quine/">quine</a>). </p> <p>A Quine is a program that, when run, prints its own source code (without resorting to easy solutions like reading its code from the filesystem). The rot13 encoding maps every letter 13 places forwards in the alphabet (wrapping around the end and preserving case). Just for fun, I wrote a quine in the rot13 encoding.</p> FizzBuzz (Python) 2009-01-14T01:51:22-08:00Louis RIVIEREhttp://code.activestate.com/recipes/users/4035877/http://code.activestate.com/recipes/576612-fizzbuzz/ <p style="color: grey"> Python recipe 576612 by <a href="/recipes/users/4035877/">Louis RIVIERE</a> (<a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/fizzbuzz/">fizzbuzz</a>). Revision 4. </p> <p>A Loopless FizzBuzz</p> Customizing polar plots in matplotlib (Python) 2008-09-06T05:31:02-07:00Kaushik Ghosehttp://code.activestate.com/recipes/users/4166965/http://code.activestate.com/recipes/576493-customizing-polar-plots-in-matplotlib/ <p style="color: grey"> Python recipe 576493 by <a href="/recipes/users/4166965/">Kaushik Ghose</a> (<a href="/recipes/tags/matplotlib/">matplotlib</a>, <a href="/recipes/tags/plots/">plots</a>, <a href="/recipes/tags/polar/">polar</a>). </p> <p>This snipped illustrates the use of thetagrids and rgrids to customize the polar plot grid</p> Prevent automated contact form submissions from spammers (Python) 2007-12-26T09:47:21-08:00Davide Andreahttp://code.activestate.com/recipes/users/2793872/http://code.activestate.com/recipes/541088-prevent-automated-contact-form-submissions-from-sp/ <p style="color: grey"> Python recipe 541088 by <a href="/recipes/users/2793872/">Davide Andrea</a> (<a href="/recipes/tags/web/">web</a>). </p> <p>Adding few lines of code will kick out the spammer by detecting that the URL of the referrer is not the URL of the form.</p> clear the screen (Python) 2006-09-04T14:52:58-07:00Ori Peleghttp://code.activestate.com/recipes/users/2056315/http://code.activestate.com/recipes/498064-clear-the-screen/ <p style="color: grey"> Python recipe 498064 by <a href="/recipes/users/2056315/">Ori Peleg</a> . </p> <p>Clear the screen on unix terminals, uses terminfo.</p> <p>terminfo inspiration courtesy of <a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/475116" rel="nofollow">http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/475116</a></p> Singleton? We don't need no stinkin' singleton: the Borg design pattern (Python) 2001-08-27T08:05:21-07:00Alex Martellihttp://code.activestate.com/recipes/users/97991/http://code.activestate.com/recipes/66531-singleton-we-dont-need-no-stinkin-singleton-the-bo/ <p style="color: grey"> Python recipe 66531 by <a href="/recipes/users/97991/">Alex Martelli</a> (<a href="/recipes/tags/oop/">oop</a>). Revision 2. </p> <p>The Singleton design pattern (DP) has a catchy name, but the wrong focus -- on identity rather than on state. The Borg design pattern has all instances share state instead, and Python makes it, literally, a snap.</p> processing options for a program that runs another program that has its own options (Python) 2006-01-26T09:06:22-08:00Rocky Bernsteinhttp://code.activestate.com/recipes/users/2752931/http://code.activestate.com/recipes/473788-processing-options-for-a-program-that-runs-another/ <p style="color: grey"> Python recipe 473788 by <a href="/recipes/users/2752931/">Rocky Bernstein</a> . </p> <p>I have a program, say a debugger, that runs another program which has options of its own. I want people to be able to give options to either program and don't want them to get confused. For example, perhaps both have "--help" options.</p> <p>So to be a little more concrete, let's say I'd like to run say program (pdb) and have it pass "--help" to a program I want it to run (specified as a command argument) called "debugged-script". I'd like to issue the command like this:</p> <p>pdb --trace debugged-script --help</p> <p>and have "--help" go to "debugged-script" and not "pdb".</p> Change the wallpaper under Windows (Python) 2005-07-01T02:37:03-07:00Sébastien Sauvagehttp://code.activestate.com/recipes/users/2503505/http://code.activestate.com/recipes/435877-change-the-wallpaper-under-windows/ <p style="color: grey"> Python recipe 435877 by <a href="/recipes/users/2503505/">Sébastien Sauvage</a> (<a href="/recipes/tags/graphics/">graphics</a>). </p> <p>Change the current wallpaper under Windows</p> How to serve files from a directory (and/or testing CGI scripts) (Python) 2005-02-02T22:34:33-08:00Michele Simionatohttp://code.activestate.com/recipes/users/1122360/http://code.activestate.com/recipes/365606-how-to-serve-files-from-a-directory-andor-testing-/ <p style="color: grey"> Python recipe 365606 by <a href="/recipes/users/1122360/">Michele Simionato</a> (<a href="/recipes/tags/web/">web</a>). </p> <p>The standard library modules SimpleHTTPServer and CGIHTTPServer are extremely useful, but the documentation hides their virtues. I hope to improve the situation with this recipe.</p> puts_tabular (Tcl) 2005-01-23T19:50:19-08:00Patrick Finneganhttp://code.activestate.com/recipes/users/1220635/http://code.activestate.com/recipes/364231-puts_tabular/ <p style="color: grey"> Tcl recipe 364231 by <a href="/recipes/users/1220635/">Patrick Finnegan</a> (<a href="/recipes/tags/windows/">windows</a>). </p> <p>Proc to write data in tabular format.</p>