Popular recipes tagged "meta:loc=4"http://code.activestate.com/recipes/tags/meta:loc=4/2017-07-17T05:53:45-07:00ActiveState Code RecipesShoelace Formula for polygonal area (Python)
2017-07-17T05:53:45-07:00Paddy McCarthyhttp://code.activestate.com/recipes/users/398009/http://code.activestate.com/recipes/580812-shoelace-formula-for-polygonal-area/
<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="http://paddy3118.blogspot.com/2017/07/python-investigation-of-shoelace.html#ixzz4n43Dqhaa" rel="nofollow">http://paddy3118.blogspot.com/2017/07/python-investigation-of-shoelace.html#ixzz4n43Dqhaa</a> " Where there is more meat on the bone (under a different license though).</p>
hollow (Perl)
2015-03-08T22:16:06-07:00Jyh Chonghttp://code.activestate.com/recipes/users/4191780/http://code.activestate.com/recipes/579033-hollow/
<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 zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578684-directories-tree/
<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 Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578621-self-counter/
<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="http://code.activestate.com/recipes/577456/">recipe 577456</a> as a variation on a theme.</p>
Linear equations solver in 3 lines (Python)
2013-03-07T07:33:09-08:00Deepakhttp://code.activestate.com/recipes/users/4183429/http://code.activestate.com/recipes/578481-linear-equations-solver-in-3-lines/
<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>>>> 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 DeadBoneshttp://code.activestate.com/recipes/users/4184772/http://code.activestate.com/recipes/578395-very-simple-password-generator-in-python/
<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="http://thelivingpearl.com/2013/01/02/generating-and-checking-passwords-in-python/">generating password</a>.</p>
How to read millions of hexadecimal numbers into a numpy array quickly (Python)
2012-06-27T06:03:40-07:00Oren Tiroshhttp://code.activestate.com/recipes/users/2033964/http://code.activestate.com/recipes/578177-how-to-read-millions-of-hexadecimal-numbers-into-a/
<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>
Change console title on clock (Batch)
2012-11-14T19:04:20-08:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578327-change-console-title-on-clock/
<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>
Recursive defaultdict (Python)
2012-03-01T19:00:04-08:00thom nealehttp://code.activestate.com/recipes/users/4176069/http://code.activestate.com/recipes/578057-recursive-defaultdict/
<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 Krikunhttp://code.activestate.com/recipes/users/4168574/http://code.activestate.com/recipes/577901-yet-another-prime-number-sieve/
<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ıhttp://code.activestate.com/recipes/users/4178739/http://code.activestate.com/recipes/577804-multiplatform-compability/
<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 Martinhttp://code.activestate.com/recipes/users/4177973/http://code.activestate.com/recipes/577694-get-a-list-from-a-configparser-option/
<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 Whitemanhttp://code.activestate.com/recipes/users/2666241/http://code.activestate.com/recipes/577386-komodo-js-macro-use-vertical-editor-tabs-positione/
<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="http://www.activestate.com/komodo-ide">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="https://developer.mozilla.org/en/XUL_Tutorial/Tabboxes#Position_of_the_tabs" rel="nofollow">https://developer.mozilla.org/en/XUL_Tutorial/Tabboxes#Position_of_the_tabs</a></p>
Accessing cursors by field name (Python)
2010-04-09T22:50:04-07:00Ricardo Araozhttp://code.activestate.com/recipes/users/4173628/http://code.activestate.com/recipes/577186-accessing-cursors-by-field-name/
<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>
Prevent star imports (Python)
2010-05-21T16:22:08-07:00Mike Grahamhttp://code.activestate.com/recipes/users/4174015/http://code.activestate.com/recipes/577237-prevent-star-imports/
<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>
Short Enum Recipe (Python)
2013-01-31T14:16:06-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577021-short-enum-recipe/
<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 Ramseyhttp://code.activestate.com/recipes/users/4169944/http://code.activestate.com/recipes/576722-pseudo-random-string/
<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 Halehttp://code.activestate.com/recipes/users/2928779/http://code.activestate.com/recipes/496817-add-support-for-the-in-operator-to-the-attributes-/
<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 Krikunhttp://code.activestate.com/recipes/users/1085177/http://code.activestate.com/recipes/365013-linear-equations-solver-in-3-lines/
<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>>>> solve("x - 2*x + 5*x - 46*(235-24) = x + 2")
3236.0
</code></pre>
toMB (Tcl)
2005-01-23T19:52:21-08:00Patrick Finneganhttp://code.activestate.com/recipes/users/1220635/http://code.activestate.com/recipes/364232-tomb/
<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>