Latest recipes tagged "meta:loc=4" Code RecipesShoelace Formula for polygonal area (Python) 2017-07-17T05:53:45-07:00Paddy McCarthy <p style="color: grey"> Python recipe 580812 by <a href="/recipes/users/398009/">Paddy McCarthy</a> (<a href="/recipes/tags/2d/">2d</a>, <a href="/recipes/tags/area/">area</a>). </p> <p>Copied, by author from "Paddy3118 Go deh!: Python investigation of the Shoelace Formula for polygonal area <a href="" rel="nofollow"></a> " Where there is more meat on the bone (under a different license though).</p> hollow (Perl) 2015-03-08T22:16:06-07:00Jyh Chong <p style="color: grey"> Perl recipe 579033 by <a href="/recipes/users/4191780/">Jyh Chong</a> . </p> <h4 id="usrbinperl-w">!/usr/bin/perl -w</h4> <pre class="prettyprint"><code> print "Content-type: text/html\n\n"; print "Hello, world"; </code></pre> Directories tree (Bash) 2013-10-11T07:11:24-07:00greg zakharov <p style="color: grey"> Bash recipe 578684 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/tree/">tree</a>). </p> <p>Imitation of tree -d command.</p> Self Counter (Python) 2013-08-02T03:15:12-07:00Stephen Chappell <p style="color: grey"> Python recipe 578621 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/counter/">counter</a>). </p> <p>This script was written as a revision of <a href="">recipe 577456</a> as a variation on a theme.</p> Linear equations solver in 3 lines (Python) 2013-03-07T07:33:09-08:00Deepak <p style="color: grey"> Python recipe 578481 by <a href="/recipes/users/4183429/">Deepak</a> (<a href="/recipes/tags/programs/">programs</a>). </p> <p>Just a little bit of hack: a linear equations solver using eval and built-in complex numbers:</p> <pre class="prettyprint"><code>&gt;&gt;&gt; solve("x - 2*x + 5*x - 46*(235-24) = x + 2") 3236.0 </code></pre> Very Simple Password Generator in Python (Python) 2013-01-02T14:28:34-08:00Captain DeadBones <p style="color: grey"> Python recipe 578395 by <a href="/recipes/users/4184772/">Captain DeadBones</a> (<a href="/recipes/tags/password/">password</a>, <a href="/recipes/tags/password_generator/">password_generator</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>A one liner password generator in python. Was writen as part of an article I wrote on <a href="">generating password</a>.</p> Change console title on clock (Batch) 2012-11-14T19:04:20-08:00greg zakharov <p style="color: grey"> Batch recipe 578327 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/clock/">clock</a>). </p> <p>Use Ctrl+C to break executing script.</p> How to read millions of hexadecimal numbers into a numpy array quickly (Python) 2012-06-27T06:03:40-07:00Oren Tirosh <p style="color: grey"> Python recipe 578177 by <a href="/recipes/users/2033964/">Oren Tirosh</a> (<a href="/recipes/tags/numpy/">numpy</a>). </p> <p>The numpy.fromfile() function supports binary formats or decimal text. How do you read millions of hexadecimal numbers quickly?</p> Recursive defaultdict (Python) 2012-03-01T19:00:04-08:00thom neale <p style="color: grey"> Python recipe 578057 by <a href="/recipes/users/4176069/">thom neale</a> (<a href="/recipes/tags/defaultdict/">defaultdict</a>). </p> <p>A defaultdict that yields a defaultdict that yields a defaultdict, etc...</p> Yet another prime number sieve (Python) 2011-10-10T07:49:08-07:00Maxim Krikun <p style="color: grey"> Python recipe 577901 by <a href="/recipes/users/4168574/">Maxim Krikun</a> (<a href="/recipes/tags/sieve/">sieve</a>). </p> <p>A one-liner that returns the list of prime numbers up to n. The inner lambda is the sieve.</p> Multiplatform compability (Python) 2011-07-24T05:10:04-07:00Yaşar Arabacı <p style="color: grey"> Python recipe 577804 by <a href="/recipes/users/4178739/">Yaşar Arabacı</a> . </p> <p>I use this small code close to the head of section of my codes if I'm going to use range function to make it behave same in both python 3 and python 2</p> Get a list from a ConfigParser option (Python) 2011-05-13T13:53:56-07:00Georges Martin <p style="color: grey"> Python recipe 577694 by <a href="/recipes/users/4177973/">Georges Martin</a> (<a href="/recipes/tags/configparser/">configparser</a>, <a href="/recipes/tags/list/">list</a>, <a href="/recipes/tags/option/">option</a>). Revision 2. </p> <p>Return a list from a ConfigParser option. By default, split on a comma and strip whitespaces.</p> Komodo JS Macro - use vertical editor tabs positioned to the right (JavaScript) 2010-09-10T02:53:33-07:00Todd Whiteman <p style="color: grey"> JavaScript recipe 577386 by <a href="/recipes/users/2666241/">Todd Whiteman</a> (<a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/layout/">layout</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/tab/">tab</a>). </p> <p>A <a href="">Komodo</a> JavaScript macro that can be used to position the editor tabs on the right side and shown vertically.</p> <p>Additional layouts (left, right, up, down, vertical, horizontal) can be made with different combinations, see here for the Mozilla tabbox positioning documentation: <a href="" rel="nofollow"></a></p> Prevent star imports (Python) 2010-05-21T16:22:08-07:00Mike Graham <p style="color: grey"> Python recipe 577237 by <a href="/recipes/users/4174015/">Mike Graham</a> (<a href="/recipes/tags/import/">import</a>). </p> <p>Use this code in your module to prevent people using the "from foo import *" syntax with your module.</p> Accessing cursors by field name (Python) 2010-04-09T22:50:04-07:00Ricardo Araoz <p style="color: grey"> Python recipe 577186 by <a href="/recipes/users/4173628/">Ricardo Araoz</a> (<a href="/recipes/tags/cursor/">cursor</a>, <a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/datastructures/">datastructures</a>, <a href="/recipes/tags/field/">field</a>, <a href="/recipes/tags/name/">name</a>). </p> <p>This class allows you to access the rows of a cursor by field name.</p> Short Enum Recipe (Python) 2013-01-31T14:16:06-08:00Stephen Chappell <p style="color: grey"> Python recipe 577021 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/enum/">enum</a>, <a href="/recipes/tags/quick/">quick</a>, <a href="/recipes/tags/short/">short</a>). Revision 9. </p> <p>If you want a small code snippet for enumerations in Python and the following code is sufficient for your needs, please go ahead and use it! Running the code is as simple as this: <code>STATE = enum('GET_QUIZ, GET_VERSE, TEACH')</code></p> <p>This recipe was edited and adapted after the author was inspired by seeing other, better enum recipes lying around.</p> pseudo-random string (Python) 2009-04-21T18:56:01-07:00Patrick Ramsey <p style="color: grey"> Python recipe 576722 by <a href="/recipes/users/4169944/">Patrick Ramsey</a> (<a href="/recipes/tags/password/">password</a>, <a href="/recipes/tags/random/">random</a>, <a href="/recipes/tags/string/">string</a>). Revision 3. </p> <p>Returns a random, password-suitable string with the specified number of characters. base64 stores 6 bits in each (8-bit) output character, hence the coefficient.</p> Add support for the "in" operator to the attributes map of minidom elements (Python) 2006-06-23T18:54:14-07:00Walker Hale <p style="color: grey"> Python recipe 496817 by <a href="/recipes/users/2928779/">Walker Hale</a> (<a href="/recipes/tags/xml/">xml</a>). Revision 2. </p> <p>When you parse XML using minidom, you can get a map of attributes for any element. The problem is that using the "in" operator on this map will raise an exception. These three lines of code will fix that.</p> Linear equations solver in 3 lines (Python) 2005-01-31T22:06:30-08:00Maxim Krikun <p style="color: grey"> Python recipe 365013 by <a href="/recipes/users/1085177/">Maxim Krikun</a> (<a href="/recipes/tags/programs/">programs</a>). Revision 2. </p> <p>Just a little bit of hack: a linear equations solver using eval and built-in complex numbers:</p> <pre class="prettyprint"><code>&gt;&gt;&gt; solve("x - 2*x + 5*x - 46*(235-24) = x + 2") 3236.0 </code></pre> toMB (Tcl) 2005-01-23T19:52:21-08:00Patrick Finnegan <p style="color: grey"> Tcl recipe 364232 by <a href="/recipes/users/1220635/">Patrick Finnegan</a> (<a href="/recipes/tags/windows/">windows</a>). </p> <p>Proc to convert bytes to megabytes.</p>