Top-rated recipes tagged "meta:loc=4"http://code.activestate.com/recipes/tags/meta:loc=4/top/2017-07-17T05:53:45-07:00ActiveState Code RecipesLinear 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>
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>
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>
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>
Shoelace 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>
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>
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>
Add Commas to a Number (Tcl)
2001-09-09T21:21:34-07:00Keith Vetterhttp://code.activestate.com/recipes/users/130056/http://code.activestate.com/recipes/68381-add-commas-to-a-number/
<p style="color: grey">
Tcl
recipe 68381
by <a href="/recipes/users/130056/">Keith Vetter</a>
(<a href="/recipes/tags/text/">text</a>).
</p>
<p>Takes a number and inserts a comma (or separator of your choice) between
every third digit.</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>
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>
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>
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>
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>
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>
Generator for splitting a string on parts of equal size (Python)
2004-08-26T03:05:46-07:00Dmitry Vasilievhttp://code.activestate.com/recipes/users/1571302/http://code.activestate.com/recipes/302069-generator-for-splitting-a-string-on-parts-of-equal/
<p style="color: grey">
Python
recipe 302069
by <a href="/recipes/users/1571302/">Dmitry Vasiliev</a>
(<a href="/recipes/tags/shortcuts/">shortcuts</a>).
</p>
<p>Example:
<pre></p>
<pre class="prettyprint"><code>>>> list(splitIterator("102030405", 2))
['10', '20', '30', '40', '5']
</pre>
</code></pre>
Grabbing text between HTML tags (Python)
2003-08-20T09:46:47-07:00Brendan Barryhttp://code.activestate.com/recipes/users/1326592/http://code.activestate.com/recipes/217019-grabbing-text-between-html-tags/
<p style="color: grey">
Python
recipe 217019
by <a href="/recipes/users/1326592/">Brendan Barry</a>
(<a href="/recipes/tags/web/">web</a>).
</p>
<p>Just a snippet. I needed to grab the data between <LI> list item </LI> tags. Highly annoying that I couldn't find it anywhere else.</p>
Generating a list of prime numbers in one statement (Python)
2002-11-14T03:43:47-08:00Pierre Denishttp://code.activestate.com/recipes/users/112275/http://code.activestate.com/recipes/162479-generating-a-list-of-prime-numbers-in-one-statemen/
<p style="color: grey">
Python
recipe 162479
by <a href="/recipes/users/112275/">Pierre Denis</a>
.
</p>
<p>The following expression generates the list of prime numbers strictly inferior to a given positive integer N.</p>
fibonacci (Python)
2002-04-04T08:08:41-08:00anurag uniyalhttp://code.activestate.com/recipes/users/127639/http://code.activestate.com/recipes/67677-fibonacci/
<p style="color: grey">
Python
recipe 67677
by <a href="/recipes/users/127639/">anurag uniyal</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>).
Revision 2.
</p>
<p>One Liner fibonacci series generator</p>