Popular recipes tagged "meta:loc=21"http://code.activestate.com/recipes/tags/meta:loc=21/2017-04-17T11:25:02-07:00ActiveState Code RecipesFrame with border color for Tkinter (Python) 2017-04-17T11:25:02-07:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/580735-frame-with-border-color-for-tkinter/ <p style="color: grey"> Python recipe 580735 by <a href="/recipes/users/4189907/">Miguel Martínez López</a> (<a href="/recipes/tags/border/">border</a>, <a href="/recipes/tags/color/">color</a>, <a href="/recipes/tags/frame/">frame</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). </p> <p>This trick show how to add a border color to frame. These are the important configurations:</p> <pre class="prettyprint"><code> highlightbackground="your border color here" highlightcolor="your border color here" highlightthickness="the border width" bd= 0 </code></pre> ctypes CDLL with automatic errno checking (Python) 2017-01-03T10:31:26-08:00Oren Tiroshhttp://code.activestate.com/recipes/users/2033964/http://code.activestate.com/recipes/580741-ctypes-cdll-with-automatic-errno-checking/ <p style="color: grey"> Python recipe 580741 by <a href="/recipes/users/2033964/">Oren Tirosh</a> . </p> <p>This class extends ctypes.CDLL with automatic checking of errno and automatically raises an exception when set by the function.</p> Using ctypes to call C code from Python (Python) 2016-05-09T18:00:44-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580660-using-ctypes-to-call-c-code-from-python/ <p style="color: grey"> Python recipe 580660 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/ffi/">ffi</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/time/">time</a>). </p> <p>This recipe shows basic usage of the ctypes module to call C code from Python code.</p> Recursively dumping the structure of an HTML5 document (Python) 2015-02-09T20:09:30-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/579022-recursively-dumping-the-structure-of-an-html5-docu/ <p style="color: grey"> Python recipe 579022 by <a href="/recipes/users/4173351/">Vasudev Ram</a> . </p> <p>This recipe shows how to dump the structure of an HTML5 document, using the html5lib Python library with recursion.</p> Numbers as Ranges - iterable integers (C++) 2014-10-02T12:13:52-07:00elazarhttp://code.activestate.com/recipes/users/4187847/http://code.activestate.com/recipes/578945-numbers-as-ranges-iterable-integers/ <p style="color: grey"> C++ recipe 578945 by <a href="/recipes/users/4187847/">elazar</a> (<a href="/recipes/tags/iterable/">iterable</a>, <a href="/recipes/tags/range/">range</a>). Revision 2. </p> <p>This header file makes simple integers iterable. Note that it works only on C++11 or above.</p> <p>Usage:</p> <pre class="prettyprint"><code>#include "num_range.h" for (int i : 3) cout &lt;&lt; i &lt;&lt; endl; </code></pre> <p>Output: 0 1 2</p> <p>Implementation note: This code is far too generic. We only need <code>DerefableInt</code>. The templates are there for no practical reason.</p> <p>Cons: pollutes namespace std; nonstandard idiom;</p> Prime Factorization (Python) 2014-09-19T08:11:54-07:00juanhttp://code.activestate.com/recipes/users/4190606/http://code.activestate.com/recipes/578938-prime-factorization/ <p style="color: grey"> Python recipe 578938 by <a href="/recipes/users/4190606/">juan</a> . </p> <p>Calculates the prime factorization from a number.</p> Dice (Python) 2014-06-12T22:03:16-07:00Drew Stanly Kolukhttp://code.activestate.com/recipes/users/4190188/http://code.activestate.com/recipes/578890-dice/ <p style="color: grey"> Python recipe 578890 by <a href="/recipes/users/4190188/">Drew Stanly Koluk</a> (<a href="/recipes/tags/dice/">dice</a>). Revision 2. </p> <p>this is a small program i wrote. it has 2 dice that go from 1 to 12 if you would like another program with only 1 die or the dice only go from 1 to 6 anything like that feel free to email me or just change it yourself(if u can)</p> <p>email:shogundrew@hotmail.com </p> Wrap a string in a file-like object that calls a user callback whenever read() is called on the stream (Python) 2013-09-22T21:48:03-07:00Ben Hoythttp://code.activestate.com/recipes/users/4170919/http://code.activestate.com/recipes/578669-wrap-a-string-in-a-file-like-object-that-calls-a-u/ <p style="color: grey"> Python recipe 578669 by <a href="/recipes/users/4170919/">Ben Hoyt</a> (<a href="/recipes/tags/callback/">callback</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/progress/">progress</a>, <a href="/recipes/tags/upload/">upload</a>). </p> <p>Wraps a string in a read-only file-like object, but also calls a user callback with the number of bytes read whenever <code>read()</code> is called on the stream. Used for tracking upload progress, for example for a progress bar in a UI application.</p> Shuffle (Python) 2013-02-19T11:01:01-08:00Narayana Chikkamhttp://code.activestate.com/recipes/users/4174427/http://code.activestate.com/recipes/578466-shuffle/ <p style="color: grey"> Python recipe 578466 by <a href="/recipes/users/4174427/">Narayana Chikkam</a> (<a href="/recipes/tags/shuffle/">shuffle</a>). </p> <p>Python function to shuffle a deck of cards</p> Monday of first week per year (not first Monday) (Python) 2012-10-31T04:37:28-07:00Scott S-Allenhttp://code.activestate.com/recipes/users/4181178/http://code.activestate.com/recipes/578308-monday-of-first-week-per-year-not-first-monday/ <p style="color: grey"> Python recipe 578308 by <a href="/recipes/users/4181178/">Scott S-Allen</a> (<a href="/recipes/tags/date/">date</a>, <a href="/recipes/tags/week/">week</a>). Revision 4. </p> <p>13th week of any year is ambiguous without identifying the first week. </p> <p>This recipe calculates Monday of the first week, not the first Monday, and differs from others by not using flow-control statement (if).</p> Creating array into batch (Batch) 2012-11-01T18:35:05-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578314-creating-array-into-batch/ <p style="color: grey"> Batch recipe 578314 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/array/">array</a>). Revision 2. </p> <p>Command language supports creation array. For example:</p> Android Gmail: export messages from SQLite database blobs (Python) 2013-03-22T11:45:11-07:00ccpizzahttp://code.activestate.com/recipes/users/4170754/http://code.activestate.com/recipes/578106-android-gmail-export-messages-from-sqlite-database/ <p style="color: grey"> Python recipe 578106 by <a href="/recipes/users/4170754/">ccpizza</a> (<a href="/recipes/tags/android/">android</a>, <a href="/recipes/tags/sqlite/">sqlite</a>). Revision 5. </p> <p>This script will extract email message bodies from the SQLite database stored in an android phone.</p> <p>The gmail database is typically located on your phone under the following location:</p> <pre class="prettyprint"><code>`\data\data\com.google.android.gm\databases\mailstore.YOURUSERNAME@gmail.com.db` </code></pre> <p>To use the script, copy the file above from your phone to your machine and rename it to <code>gmail.db</code>.</p> <p><em>NOTE:</em> You need a rooted phone in order to get access to the folder above.</p> Triangle Tooth Gear for Physion (JavaScript) 2012-05-10T16:42:33-07:00Isendrak Skatasmidhttp://code.activestate.com/recipes/users/4182031/http://code.activestate.com/recipes/578124-triangle-tooth-gear-for-physion/ <p style="color: grey"> JavaScript recipe 578124 by <a href="/recipes/users/4182031/">Isendrak Skatasmid</a> (<a href="/recipes/tags/addon/">addon</a>). </p> <p>This Script adds a Function for creating a Gear with Triangle shaped Teeth to Physion.</p> Bazaar as a setuptools file finder (Python) 2011-10-25T12:25:34-07:00Graham Poulterhttp://code.activestate.com/recipes/users/4172291/http://code.activestate.com/recipes/577910-bazaar-as-a-setuptools-file-finder/ <p style="color: grey"> Python recipe 577910 by <a href="/recipes/users/4172291/">Graham Poulter</a> (<a href="/recipes/tags/bazaar/">bazaar</a>, <a href="/recipes/tags/setuptools/">setuptools</a>). </p> <p>Use Bazaar to list files for setup.py installation.</p> Bifurcation diagram of logistic map (Python) 2010-07-24T02:40:54-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577332-bifurcation-diagram-of-logistic-map/ <p style="color: grey"> Python recipe 577332 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>). Revision 2. </p> <p>Bifurcation diagram of the logistic map.</p> Numerical Integration using random sampling (Python) 2010-06-30T04:28:10-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577276-numerical-integration-using-random-sampling/ <p style="color: grey"> Python recipe 577276 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/random/">random</a>). </p> <p>Numerical Integration using random sampling.</p> Komodo JS Macro - Search word under cursor (no need to select it) (JavaScript) 2010-03-30T16:41:00-07:00Davide Ficanohttp://code.activestate.com/recipes/users/4166571/http://code.activestate.com/recipes/577169-komodo-js-macro-search-word-under-cursor-no-need-t/ <p style="color: grey"> JavaScript recipe 577169 by <a href="/recipes/users/4166571/">Davide Ficano</a> (<a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>). </p> <p>Search word under cursor (no need to select it). If no word it is possible to determine (eg. cursor is near a bracket) search by the last used find pattern</p> Move Firefly/Trac wiki pages (Python) 2010-02-22T12:54:33-08:00Troy Topnikhttp://code.activestate.com/recipes/users/4165698/http://code.activestate.com/recipes/577062-move-fireflytrac-wiki-pages/ <p style="color: grey"> Python recipe 577062 by <a href="/recipes/users/4165698/">Troy Topnik</a> (<a href="/recipes/tags/firefly/">firefly</a>, <a href="/recipes/tags/trac/">trac</a>, <a href="/recipes/tags/wiki/">wiki</a>, <a href="/recipes/tags/xmlrpc/">xmlrpc</a>). Revision 2. </p> <p>Moves all wiki pages from one Firefly (Trac) project to another (optionally deleting all wiki pages in the target project first).</p> <p>The full xml-rpc API can be found in every Firefly project. For example: <a href="http://firefly.activestate.com/troyt/sandbox/xmlrpc" rel="nofollow">http://firefly.activestate.com/troyt/sandbox/xmlrpc</a></p> Two-finger iterator (Python) 2010-01-09T15:06:51-08:00Karl Dickmanhttp://code.activestate.com/recipes/users/4172760/http://code.activestate.com/recipes/576997-two-finger-iterator/ <p style="color: grey"> Python recipe 576997 by <a href="/recipes/users/4172760/">Karl Dickman</a> . </p> <p>Sometimes it's useful to iterate through a series of items, looking at an item and the next one.</p> Generate a salt (PHP) 2012-07-10T19:52:17-07:00Xavier L.http://code.activestate.com/recipes/users/4171602/http://code.activestate.com/recipes/576894-generate-a-salt/ <p style="color: grey"> PHP recipe 576894 by <a href="/recipes/users/4171602/">Xavier L.</a> (<a href="/recipes/tags/crypt/">crypt</a>, <a href="/recipes/tags/generation/">generation</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/pass/">pass</a>, <a href="/recipes/tags/password/">password</a>, <a href="/recipes/tags/salt/">salt</a>, <a href="/recipes/tags/secure/">secure</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/string/">string</a>). Revision 6. </p> <p>This function will generate a salt for use with passwords ranging using characters in range a to z, A to Z, 0 to 9 and !@#$%&amp;<em>?. The characters are sorted in a random value and can appear more than one time in the string. This way, this function is more powerful than the *shuffle()</em> function. This means that the salt could also be longer than the character list.</p>