Popular recipes tagged "meta:loc=67"http://code.activestate.com/recipes/tags/meta:loc=67/2016-07-31T22:50:28-07:00ActiveState Code RecipesImage Projection Onto Sphere (Python)
2016-07-31T22:50:28-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/580695-image-projection-onto-sphere/
<p style="color: grey">
Python
recipe 580695
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/image_processing/">image_processing</a>, <a href="/recipes/tags/imaging/">imaging</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/pil/">pil</a>).
</p>
<p>Image projection onto sphere using Equirectangular map projection.</p>
<p>Download the test image from the Wikipedia page!</p>
Create PDF control break reports with itertools.groupby and xtopdf (Python)
2016-07-23T22:17:29-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580692-create-pdf-control-break-reports-with-itertoolsgro/
<p style="color: grey">
Python
recipe 580692
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/control/">control</a>, <a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/grouping/">grouping</a>, <a href="/recipes/tags/iterators/">iterators</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/pdf_generation/">pdf_generation</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/reportgeneration/">reportgeneration</a>, <a href="/recipes/tags/reporting/">reporting</a>, <a href="/recipes/tags/sql/">sql</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>).
</p>
<p>This recipe shows how to create the classic control break style of report (a staple of data processing) using Python along with the groupby function from the itertools module, and xtopdf, a Python toolkit for PDF creation.</p>
OrderedSet (Python)
2015-06-25T17:33:13-07:00Sanderhttp://code.activestate.com/recipes/users/4192426/http://code.activestate.com/recipes/579071-orderedset/
<p style="color: grey">
Python
recipe 579071
by <a href="/recipes/users/4192426/">Sander</a>
(<a href="/recipes/tags/ordered/">ordered</a>, <a href="/recipes/tags/set/">set</a>).
</p>
<p>Set that remembers original insertion order.</p>
OrderedSet (Python)
2012-12-19T07:12:32-08:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/576694-orderedset/
<p style="color: grey">
Python
recipe 576694
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/ordered/">ordered</a>, <a href="/recipes/tags/set/">set</a>).
Revision 9.
</p>
<p>Set that remembers original insertion order.</p>
A script to automate installing MTS Mblaze UI in linux (Bash)
2015-07-29T18:26:59-07:00Emil george jameshttp://code.activestate.com/recipes/users/4191910/http://code.activestate.com/recipes/579039-a-script-to-automate-installing-mts-mblaze-ui-in-l/
<p style="color: grey">
Bash
recipe 579039
by <a href="/recipes/users/4191910/">Emil george james</a>
(<a href="/recipes/tags/internet/">internet</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/script/">script</a>, <a href="/recipes/tags/shell/">shell</a>, <a href="/recipes/tags/web/">web</a>).
</p>
<p>An automate shell linux script to install mts mblaze ui application in all linux distros.this shell script automatically install the mts mblaze ui in your linux systems .installation script will setup everything need to choose some option interactively from setup.Script can work for all linux environments.</p>
Progress bar class (Python)
2012-08-09T17:39:10-07:00Xavier L.http://code.activestate.com/recipes/users/4171602/http://code.activestate.com/recipes/578228-progress-bar-class/
<p style="color: grey">
Python
recipe 578228
by <a href="/recipes/users/4171602/">Xavier L.</a>
(<a href="/recipes/tags/class/">class</a>, <a href="/recipes/tags/cli/">cli</a>, <a href="/recipes/tags/curses/">curses</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/module/">module</a>, <a href="/recipes/tags/progress/">progress</a>).
Revision 5.
</p>
<p>See <a href="https://gist.github.com/3306295">gist:3306295</a> for future developments.</p>
<p>Here is a little class that lets you present percent complete information in the form of a progress bar using the '=' character to represent completed portions, spaces to represent incomplete portions, '>' to represent the current portion and the actual percent done (rounded to integer) displayed at the end:</p>
<p>[===========> ] 60%</p>
<p>When you initialize the class, you specify the minimum number (defaults to 0), the maximum number (defaults to 100), and the desired width of the progress bar. The brackets <code>[]</code> are included in the size of the progress bar, but you must allow for up to 4 characters extra to display the percentage.</p>
<p>You'd probably want to use this in conjuction with the curses module, or something like that so you can over-write the same portion of the screen to make your updates 'animated'.</p>
GTIN Validate Check Digit or Add Check Digit (Python)
2011-11-26T07:12:18-08:00Richard Thiemanhttp://code.activestate.com/recipes/users/4180084/http://code.activestate.com/recipes/577963-gtin-validate-check-digit-or-add-check-digit/
<p style="color: grey">
Python
recipe 577963
by <a href="/recipes/users/4180084/">Richard Thieman</a>
(<a href="/recipes/tags/check/">check</a>, <a href="/recipes/tags/digits/">digits</a>, <a href="/recipes/tags/gtin/">gtin</a>).
</p>
<p>A python class I wrote to add or validate a GTIN check digit.</p>
Durand-Kerner method for solving polynomial equations (Python)
2013-04-28T20:47:23-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577865-durand-kerner-method-for-solving-polynomial-equati/
<p style="color: grey">
Python
recipe 577865
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>).
Revision 2.
</p>
<p>Durand-Kerner method for solving polynomial equations.</p>
Temporary substitution of object in modules via with statement (Python)
2010-01-24T04:19:12-08:00Jacob Oscarsonhttp://code.activestate.com/recipes/users/1355144/http://code.activestate.com/recipes/577020-temporary-substitution-of-object-in-modules-via-wi/
<p style="color: grey">
Python
recipe 577020
by <a href="/recipes/users/1355144/">Jacob Oscarson</a>
(<a href="/recipes/tags/modules/">modules</a>, <a href="/recipes/tags/testing/">testing</a>, <a href="/recipes/tags/with_statement/">with_statement</a>).
</p>
<p>See docstring in the code</p>
Ordered Dictionary for Py2.7 and Py3.1 (Python)
2009-02-26T20:50:13-08:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/576669-ordered-dictionary-for-py27-and-py31/
<p style="color: grey">
Python
recipe 576669
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
.
Revision 18.
</p>
<p>Dictionary that remembers insertion order. Useful for editing XML files and config files where there are (key, value) pairs but the original order should be preserved. Similar to ordered dicts in PHP.</p>
Shell-like data processing, using Popen, pipes, and Thread (Python)
2009-05-15T03:30:43-07:00Massimo Santinihttp://code.activestate.com/recipes/users/4170290/http://code.activestate.com/recipes/576757-shell-like-data-processing-using-popen-pipes-and-t/
<p style="color: grey">
Python
recipe 576757
by <a href="/recipes/users/4170290/">Massimo Santini</a>
.
</p>
<p>This module is inspired by <a href="http://code.activestate.com/recipes/276960/">recipe 276960</a> and shows how external processes (istantiated with Popen) can be combined with a pipe-like syntax. Some support is added for having in the pipe also local functions (by caching their results in a ByteIO, or using operating system pipes). A similar approach, using generators, is presented in <a href="http://code.activestate.com/recipes/576756/">recipe 576756</a>.</p>
Get CPU Usage by using ctypes (Win32 Platform) (Python)
2009-01-26T06:43:38-08:00Shao-chuan Wanghttp://code.activestate.com/recipes/users/4168519/http://code.activestate.com/recipes/576631-get-cpu-usage-by-using-ctypes-win32-platform/
<p style="color: grey">
Python
recipe 576631
by <a href="/recipes/users/4168519/">Shao-chuan Wang</a>
(<a href="/recipes/tags/cpu_usage/">cpu_usage</a>, <a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/system_programming/">system_programming</a>, <a href="/recipes/tags/win32/">win32</a>).
Revision 2.
</p>
<p>The following code has been tested at Windows XP sp2 with Python of version 2.5.4.</p>
生成全排列数 (Python)
2009-02-22T00:03:57-08:00nillgump nillgumphttp://code.activestate.com/recipes/users/4169273/http://code.activestate.com/recipes/576659-/
<p style="color: grey">
Python
recipe 576659
by <a href="/recipes/users/4169273/">nillgump nillgump</a>
.
Revision 2.
</p>
<p>生成全排列</p>
extract emails from a mbox read on stdin (Python)
2013-09-07T10:24:17-07:00Romain Dartigueshttp://code.activestate.com/recipes/users/4167472/http://code.activestate.com/recipes/576553-extract-emails-from-a-mbox-read-on-stdin/
<p style="color: grey">
Python
recipe 576553
by <a href="/recipes/users/4167472/">Romain Dartigues</a>
(<a href="/recipes/tags/email/">email</a>, <a href="/recipes/tags/generators/">generators</a>, <a href="/recipes/tags/mbox/">mbox</a>, <a href="/recipes/tags/read_only/">read_only</a>, <a href="/recipes/tags/stdin/">stdin</a>).
Revision 2.
</p>
<p>The Python <code>mailbox.mbox</code> class require a real file to initialize, which was an issue in my case. These simple functions let you iter through a mailbox read from a read-only file descriptor (like <code>sys.stdin</code>).</p>
<p>This script use the generators which were introduced in Python-2.2. Let me know if you are interested a similar functionnality on older Python versions.</p>
Using the python imaging library to generate degraded letter stimuli (Python)
2008-09-06T05:24:33-07:00Kaushik Ghosehttp://code.activestate.com/recipes/users/4166965/http://code.activestate.com/recipes/576490-using-the-python-imaging-library-to-generate-degra/
<p style="color: grey">
Python
recipe 576490
by <a href="/recipes/users/4166965/">Kaushik Ghose</a>
(<a href="/recipes/tags/imaging/">imaging</a>, <a href="/recipes/tags/library/">library</a>, <a href="/recipes/tags/science/">science</a>, <a href="/recipes/tags/stimuli/">stimuli</a>, <a href="/recipes/tags/visual/">visual</a>).
</p>
<p>Code to generate degraded letter stimuli, as used in the paper "The remarkable inefficiency of word recognition" (Pelli et al. 2003). Utilizes the Python Imaging Library, and is an example of the usage of this library.</p>
Byte to Hex and Hex to Byte String Conversion (Python)
2007-03-21T06:35:40-07:00Simon Peveretthttp://code.activestate.com/recipes/users/1410328/http://code.activestate.com/recipes/510399-byte-to-hex-and-hex-to-byte-string-conversion/
<p style="color: grey">
Python
recipe 510399
by <a href="/recipes/users/1410328/">Simon Peverett</a>
(<a href="/recipes/tags/text/">text</a>).
</p>
<p>I write a lot of ad-hoc protocol analysers using Python. Generally, I'm dealing with a byte stream that I want to output as a string of hex. Sometimes, I want to convert it back again. Eventually, I got round to putting the functions in a module so I wouldn't keep cut and pasting them :)</p>
Skeleton script Hello World (Python)
2007-12-07T15:32:02-08:00Noah Spurrierhttp://code.activestate.com/recipes/users/103276/http://code.activestate.com/recipes/528877-skeleton-script-hello-world/
<p style="color: grey">
Python
recipe 528877
by <a href="/recipes/users/103276/">Noah Spurrier</a>
(<a href="/recipes/tags/programs/">programs</a>).
Revision 5.
</p>
<p>I write a lot of small scripts in Python. This is the template that I use to start most of my scripts. This gets me started with good documentation, argument parsing, and error handling.</p>
Reference count checking (Python)
2006-06-11T01:15:56-07:00Robin Beckerhttp://code.activestate.com/recipes/users/880795/http://code.activestate.com/recipes/496791-reference-count-checking/
<p style="color: grey">
Python
recipe 496791
by <a href="/recipes/users/880795/">Robin Becker</a>
.
</p>
<p>Whilst testing that a C extension was causing a problem with reference counts I created some code to check that the reference counts of a set of variables were not being changed by a call to a specific C method. That code itself was buggy as the output of a particular reference count eg 12 could actually modify one or more of the reference counts being checked. The solution was to store the refcount info as a string.</p>
catenateFilesFactory (Python)
2005-07-31T13:20:17-07:00Jim Jinkinshttp://code.activestate.com/recipes/users/1170097/http://code.activestate.com/recipes/438806-catenatefilesfactory/
<p style="color: grey">
Python
recipe 438806
by <a href="/recipes/users/1170097/">Jim Jinkins</a>
(<a href="/recipes/tags/files/">files</a>).
</p>
<p>Generate a catenateFiles function parameterized for
common variations.</p>
extend textwrap.TextWrapper to handle multiple paragraphs (Python)
2004-12-11T02:04:02-08:00Brett Cannonhttp://code.activestate.com/recipes/users/98030/http://code.activestate.com/recipes/358228-extend-textwraptextwrapper-to-handle-multiple-para/
<p style="color: grey">
Python
recipe 358228
by <a href="/recipes/users/98030/">Brett Cannon</a>
(<a href="/recipes/tags/text/">text</a>).
</p>
<p>textwrap is a very handy module. The problem with it, though, is that it expects to be used with individual paragraphs. But what if you want to wrap an entire document? It will still wrap the lines, but it will improperly consider it all a single paragraph.</p>
<p>This recipe alleviates that issue by overriding textwrap.TextWrapper.wrap with an implementation that handles spiltting a document into paragraphs and processing each individually. This allows things such as initial_indent to work as expected.</p>