Popular recipes tagged "meta:loc=20"http://code.activestate.com/recipes/tags/meta:loc=20/2016-08-26T00:02:48-07:00ActiveState Code RecipesFind all fonts used in a PDF document by page (Python) 2016-08-26T00:02:48-07:00Jorj X. McKiehttp://code.activestate.com/recipes/users/4193772/http://code.activestate.com/recipes/580651-find-all-fonts-used-in-a-pdf-document-by-page/ <p style="color: grey"> Python recipe 580651 by <a href="/recipes/users/4193772/">Jorj X. McKie</a> (<a href="/recipes/tags/pdf/">pdf</a>). Revision 3. </p> <p>Finds all fonts used in a PDF document by page. This new script is based on PyMuDF v1.9.2 and works for PDF files only. However, it is a lot simpler, speed has drastically improved and there is no dependency on other packages any more.</p> Check for package updates on PyPI (works best in pip+virtualenv) (Python) 2015-03-04T11:01:44-08:00migonzalvarhttp://code.activestate.com/recipes/users/4191750/http://code.activestate.com/recipes/579030-check-for-package-updates-on-pypi-works-best-in-pi/ <p style="color: grey"> Python recipe 579030 by <a href="/recipes/users/4191750/">migonzalvar</a> (<a href="/recipes/tags/pip/">pip</a>, <a href="/recipes/tags/pypi/">pypi</a>, <a href="/recipes/tags/virtualenv/">virtualenv</a>). </p> <p>Pip has an option to upgrade a package (_pip install -U_), however it always downloads sources even if there is already a newest version installed. If you want to check updates for all installed packages then some scripting is required.</p> <p>This script checks if there is a newer version on PyPI for every installed package. It only prints information about available version and doesn't do any updates. Example output:</p> <pre class="prettyprint"><code>distribute 0.6.15 0.6.16 available Baker 1.1 up to date Django 1.3 up to date ipython 0.10.2 up to date gunicorn 0.12.1 0.12.2 available pyprof2calltree 1.1.0 up to date profilestats 1.0.2 up to date mercurial 1.8.3 up to date </code></pre> grep in Python (Python) 2014-03-05T19:47:50-08:00Andy Dustmanhttp://code.activestate.com/recipes/users/2435929/http://code.activestate.com/recipes/578845-grep-in-python/ <p style="color: grey"> Python recipe 578845 by <a href="/recipes/users/2435929/">Andy Dustman</a> (<a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/grep/">grep</a>, <a href="/recipes/tags/search/">search</a>). </p> <p>The grep() function is inspired by UNIX grep, but is not limited to string patterns and files or streams.</p> Multidimensional Pareto front (Python) 2012-10-13T23:26:12-07:00Jamie Bullhttp://code.activestate.com/recipes/users/4183059/http://code.activestate.com/recipes/578287-multidimensional-pareto-front/ <p style="color: grey"> Python recipe 578287 by <a href="/recipes/users/4183059/">Jamie Bull</a> (<a href="/recipes/tags/engineering/">engineering</a>, <a href="/recipes/tags/finance/">finance</a>, <a href="/recipes/tags/optimal/">optimal</a>, <a href="/recipes/tags/pareto/">pareto</a>, <a href="/recipes/tags/pareto_front/">pareto_front</a>, <a href="/recipes/tags/pareto_frontier/">pareto_frontier</a>, <a href="/recipes/tags/pareto_set/">pareto_set</a>). Revision 2. </p> <p>Method for finding non-dominated options in multi-dimensional data.</p> Simple Substitution Cipher Algorithm (Python) 2013-06-03T17:51:00-07:00Captain DeadBoneshttp://code.activestate.com/recipes/users/4184772/http://code.activestate.com/recipes/578544-simple-substitution-cipher-algorithm/ <p style="color: grey"> Python recipe 578544 by <a href="/recipes/users/4184772/">Captain DeadBones</a> (<a href="/recipes/tags/cipher/">cipher</a>, <a href="/recipes/tags/encryption/">encryption</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>This script was written for an article I wrote It converts any plain text into a Caesar Cipher message. For more information <a href="http://thelivingpearl.com/2013/06/03/caesar-ciphers-in-python/">Caesar Ciphers In Python</a></p> Enable Clear Type font smoothing on Windows (ctypes version) (Python) 2013-05-07T09:17:56-07:00ccpizzahttp://code.activestate.com/recipes/users/4170754/http://code.activestate.com/recipes/578500-enable-clear-type-font-smoothing-on-windows-ctypes/ <p style="color: grey"> Python recipe 578500 by <a href="/recipes/users/4170754/">ccpizza</a> (<a href="/recipes/tags/fontsmoothing/">fontsmoothing</a>, <a href="/recipes/tags/windows/">windows</a>). Revision 3. </p> <p>Running the script without parameters will enable Clear Type font smoothing. Pass 0, false, off, or disable to turn off Clear Type.</p> <p>This version requires the <code>ctypes</code> module.</p> <p>For a version that uses pywin32 see <a href="http://code.activestate.com/recipes/578499-enable-clear-type-font-smoothing-on-windows-pywin3/" rel="nofollow">http://code.activestate.com/recipes/578499-enable-clear-type-font-smoothing-on-windows-pywin3/</a> </p> Byte Frequency Analyzer (Python) 2012-12-05T23:48:53-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578361-byte-frequency-analyzer/ <p style="color: grey"> Python recipe 578361 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/demonstration/">demonstration</a>). </p> <p>When beginning to compress a file or studying it to break certain forms of encryption, sometimes it is helpful to know how many bytes of a certain category are in a file. This recipe is a simple frequency analysis tool that may be helpful towards that end and can provide a starting point for those interested tools for such fields.</p> Sound Generator Using WAV file (Python) 2012-06-19T00:41:22-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578168-sound-generator-using-wav-file/ <p style="color: grey"> Python recipe 578168 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/sound/">sound</a>). </p> <p>This is an example for generating sound using wave files. It is equivalent to:</p> <p>from winsound import Beep</p> <p>Beep(freq, duration * 1000)</p> <p>But of course wave files can also be used to generate any other kinds of sounds. </p> Quickly add all dirs to sys.path if dir has .py file (Python) 2012-04-06T16:06:17-07:00Andrew Yurisichhttp://code.activestate.com/recipes/users/4180867/http://code.activestate.com/recipes/578097-quickly-add-all-dirs-to-syspath-if-dir-has-py-file/ <p style="color: grey"> Python recipe 578097 by <a href="/recipes/users/4180867/">Andrew Yurisich</a> (<a href="/recipes/tags/add/">add</a>, <a href="/recipes/tags/os_walk/">os_walk</a>, <a href="/recipes/tags/sys_path/">sys_path</a>). Revision 2. </p> <p>Add all dirs under <code>folder</code> to sys.path if any .py files are found. Use an abspath if you'd rather do it that way.</p> <p>Uses the current working directory as the location of using.py. Keep in mind that os.walk goes <em>all the way</em> down the directory tree.</p> Print a List of Places (ie, Rankings) (Python) 2012-02-25T05:37:41-08:00Andrew Yurisichhttp://code.activestate.com/recipes/users/4180867/http://code.activestate.com/recipes/578052-print-a-list-of-places-ie-rankings/ <p style="color: grey"> Python recipe 578052 by <a href="/recipes/users/4180867/">Andrew Yurisich</a> (<a href="/recipes/tags/list/">list</a>, <a href="/recipes/tags/listing/">listing</a>, <a href="/recipes/tags/ranking/">ranking</a>). </p> <p>Hopefully this function will save you the trip to oocalc/excel. Py3k code.</p> Midpoint of two GPS points (Python) 2011-05-21T22:11:01-07:00Stijn de Graafhttp://code.activestate.com/recipes/users/4178055/http://code.activestate.com/recipes/577713-midpoint-of-two-gps-points/ <p style="color: grey"> Python recipe 577713 by <a href="/recipes/users/4178055/">Stijn de Graaf</a> (<a href="/recipes/tags/circle/">circle</a>, <a href="/recipes/tags/coordinates/">coordinates</a>, <a href="/recipes/tags/gps/">gps</a>, <a href="/recipes/tags/latitude/">latitude</a>, <a href="/recipes/tags/longitude/">longitude</a>, <a href="/recipes/tags/midpoint/">midpoint</a>, <a href="/recipes/tags/orthodrome/">orthodrome</a>). </p> <p>This calculates the midpoint between two GPS coordinates along the Earth's surface. Based on formula from <a href="http://www.movable-type.co.uk/scripts/latlong.html" rel="nofollow">http://www.movable-type.co.uk/scripts/latlong.html</a></p> Check for package updates on PyPI (works best in pip+virtualenv) (Python) 2011-05-19T17:54:43-07:00Artur Siekielskihttp://code.activestate.com/recipes/users/4177664/http://code.activestate.com/recipes/577708-check-for-package-updates-on-pypi-works-best-in-pi/ <p style="color: grey"> Python recipe 577708 by <a href="/recipes/users/4177664/">Artur Siekielski</a> (<a href="/recipes/tags/pip/">pip</a>, <a href="/recipes/tags/pypi/">pypi</a>, <a href="/recipes/tags/virtualenv/">virtualenv</a>). </p> <p>Pip has an option to upgrade a package (_pip install -U_), however it always downloads sources even if there is already a newest version installed. If you want to check updates for all installed packages then some scripting is required.</p> <p>This script checks if there is a newer version on PyPI for every installed package. It only prints information about available version and doesn't do any updates. Example output:</p> <pre class="prettyprint"><code>distribute 0.6.15 0.6.16 available Baker 1.1 up to date Django 1.3 up to date ipython 0.10.2 up to date gunicorn 0.12.1 0.12.2 available pyprof2calltree 1.1.0 up to date profilestats 1.0.2 up to date mercurial 1.8.3 up to date </code></pre> IFrame Example (HTML) 2011-04-21T02:11:57-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577671-iframe-example/ <p style="color: grey"> HTML recipe 577671 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/html/">html</a>, <a href="/recipes/tags/iframe/">iframe</a>). </p> <p>IFrame demo. It opens 4 sub-browser windows inside the webpage.</p> Wiki Recent Changes Checker (Python) 2010-12-28T07:27:25-08:00Ryhttp://code.activestate.com/recipes/users/4176376/http://code.activestate.com/recipes/577522-wiki-recent-changes-checker/ <p style="color: grey"> Python recipe 577522 by <a href="/recipes/users/4176376/">Ry</a> (<a href="/recipes/tags/beautifulsoup/">beautifulsoup</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/ubuntu/">ubuntu</a>, <a href="/recipes/tags/wiki/">wiki</a>). </p> <p>Basic script that will check and see if there have been any recent changes to a Wikimedia. Used for low use Wikimedia sites to keep an eye on them. I run this whenever my box starts and it will open the browser along with a few other windows that open.</p> Komodo JS Macro - insert a relative path from the current editor file (JavaScript) 2012-02-24T00:23:09-08:00Todd Whitemanhttp://code.activestate.com/recipes/users/2666241/http://code.activestate.com/recipes/577306-komodo-js-macro-insert-a-relative-path-from-the-cu/ <p style="color: grey"> JavaScript recipe 577306 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/macro/">macro</a>, <a href="/recipes/tags/path/">path</a>, <a href="/recipes/tags/relative/">relative</a>). Revision 3. </p> <p>A <a href="http://www.activestate.com/komodo">Komodo</a> JavaScript macro that can be used to generate a relative path from the current editor file location, which works great for HTML when linking to relative style sheets, images, etc...</p> <p>Upon execution of this macro, you will be prompted to browse and select the target file, then upon selecting the target path, the relative path location will be inserted into the editor at the current position.</p> <p>To best use this macro - assign a custom key-binding to the macro and then trigger the macro at will.</p> Yet another roundrobin (Python) 2010-07-19T13:53:41-07:00Daniel Cohnhttp://code.activestate.com/recipes/users/4172918/http://code.activestate.com/recipes/577309-yet-another-roundrobin/ <p style="color: grey"> Python recipe 577309 by <a href="/recipes/users/4172918/">Daniel Cohn</a> (<a href="/recipes/tags/collections/">collections</a>, <a href="/recipes/tags/itertools/">itertools</a>, <a href="/recipes/tags/roundrobin/">roundrobin</a>). Revision 2. </p> <p>This recipe provides a decently simple implementation of a roundrobin using itertools and deque.</p> Use DebugView utility with standard python logging (Python) 2010-02-10T10:35:59-08:00Christopher Prinoshttp://code.activestate.com/recipes/users/481494/http://code.activestate.com/recipes/577040-use-debugview-utility-with-standard-python-logging/ <p style="color: grey"> Python recipe 577040 by <a href="/recipes/users/481494/">Christopher Prinos</a> (<a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/debugview/">debugview</a>, <a href="/recipes/tags/logging/">logging</a>, <a href="/recipes/tags/sysinternals/">sysinternals</a>, <a href="/recipes/tags/windows/">windows</a>). </p> <p>This is a custom logging.Handler class that lets you use standard logging calls to output messages to SysInternals' DebugView utility.</p> Sort file (with unique option) (JavaScript) 2010-05-30T21:47:36-07:00Glenn Jenkinshttp://code.activestate.com/recipes/users/4174057/http://code.activestate.com/recipes/577247-sort-file-with-unique-option/ <p style="color: grey"> JavaScript recipe 577247 by <a href="/recipes/users/4174057/">Glenn Jenkins</a> (<a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/sort/">sort</a>, <a href="/recipes/tags/unique/">unique</a>). </p> <p>This will sort the lines in the current document into alphabetical order. It doesn't apply any special rule (so 5 will come <em>after</em> 42).</p> <p>On running, it asks if you want a unique sort (Cancel for no, Ok for yes), in which case it'll remove duplicate lines.</p> Object Wrapper (Python) 2010-05-05T17:02:42-07:00Dmitryhttp://code.activestate.com/recipes/users/4173772/http://code.activestate.com/recipes/577215-object-wrapper/ <p style="color: grey"> Python recipe 577215 by <a href="/recipes/users/4173772/">Dmitry</a> (<a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/object/">object</a>, <a href="/recipes/tags/wrapper/">wrapper</a>). </p> <p>There is classical wrapper on Python language. If you have only object and can't change object generation you can use this class.</p> Komodo Macro - Clear all "Most Recent Used" lists (JavaScript) 2010-04-14T07:18:39-07:00Davide Ficanohttp://code.activestate.com/recipes/users/4166571/http://code.activestate.com/recipes/577192-komodo-macro-clear-all-most-recent-used-lists/ <p style="color: grey"> JavaScript recipe 577192 by <a href="/recipes/users/4166571/">Davide Ficano</a> (<a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/mru/">mru</a>). </p> <p>Clear all Komodo Most Recent Used lists</p>