Popular recipes tagged "meta:loc=179"http://code.activestate.com/recipes/tags/meta:loc=179/2014-03-23T22:31:40-07:00ActiveState Code RecipesTrack Debug Package argument(s) are option(s) and/or a debug message to be saved to a file (Tcl) 2014-03-23T22:31:40-07:00Bert Byfieldhttp://code.activestate.com/recipes/users/4188497/http://code.activestate.com/recipes/578855-track-debug-package-arguments-are-options-andor-a-/ <p style="color: grey"> Tcl recipe 578855 by <a href="/recipes/users/4188497/">Bert Byfield</a> (<a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/pdisplay/">pdisplay</a>, <a href="/recipes/tags/ptrack/">ptrack</a>, <a href="/recipes/tags/trace/">trace</a>, <a href="/recipes/tags/track/">track</a>, <a href="/recipes/tags/tracklst/">tracklst</a>). </p> &lt;h4 id="package-require-tracks"&gt;package require tracks&lt;/h4&gt; &lt;h4 id="ptrack-on-off-clear-overflow-overflowgo-abend-104-message-text"&gt;pTrack ?-on? ?-off? ?-clear? ?-overflow? ?-overflowGo? ?-abend? ?"104 message text"?&lt;/h4&gt; <p>A user-specified text message is written to a file "tracklst.txt" in the same directory as the source program. Tracking can be turned on or off, and the clear option sets the file to zero bytes. The program defaults to raise an error if the tracklst.txt file gets too big (default is one megabyte), but the overflowGo option will cause it to just turn off tracking and continue. The abend option will raise an optional error. The message is whatever the user wants it to be, but suggested usage is to always start with three digits that identify a proc and a fourth alphabetic character that marks the track uniquely and allows searching for a specific track. Also includes pDisplay, which writes a debug message to a tk_messageBox dialog window.</p> <p>e.g.: pTrack -clear "Start a new test by emptying the track file" <br> pTrack "140d date adjusted to $tMon of $tYear" pTrack "135b Current working directory is [pwd]"</p> Distributed lock manager for Python (Python) 2012-07-04T21:03:32-07:00pavelhttp://code.activestate.com/recipes/users/4171837/http://code.activestate.com/recipes/578194-distributed-lock-manager-for-python/ <p style="color: grey"> Python recipe 578194 by <a href="/recipes/users/4171837/">pavel</a> (<a href="/recipes/tags/distributed/">distributed</a>, <a href="/recipes/tags/lock/">lock</a>, <a href="/recipes/tags/locking/">locking</a>, <a href="/recipes/tags/locks/">locks</a>, <a href="/recipes/tags/manager/">manager</a>, <a href="/recipes/tags/socket/">socket</a>, <a href="/recipes/tags/thread/">thread</a>, <a href="/recipes/tags/threading/">threading</a>, <a href="/recipes/tags/wsgi/">wsgi</a>). Revision 2. </p> <p>Distributed lock manager provides mutex(es) over network. It is used to synchronize processes running on different machines, e.g. WSGI processes in case of web applications. Lock object is compatible with threading.Lock and can be used as a context manager ("with statement"). It can be easily modified to use UNIX sockets instead of TCP/IP. Communication protocol is text based.</p> <p>First start server process:</p> <pre class="prettyprint"><code>$ chmod +x dlm.py $ ./dlm.py </code></pre> <p>Usage:</p> <pre class="prettyprint"><code>from dlm import LockClient client = LockClient('localhost', 27272, 'client_name') lock = client.mkLock('lock_name') lock.acquire() # critical section here... lock.release() # using context manager with lock: # critical section here... </code></pre> Multithreading Downloader Class (Python) 2012-07-22T07:44:20-07:00Itay Brandeshttp://code.activestate.com/recipes/users/4182927/http://code.activestate.com/recipes/578220-multithreading-downloader-class/ <p style="color: grey"> Python recipe 578220 by <a href="/recipes/users/4182927/">Itay Brandes</a> (<a href="/recipes/tags/downloader/">downloader</a>, <a href="/recipes/tags/multithread/">multithread</a>, <a href="/recipes/tags/multithreading/">multithreading</a>, <a href="/recipes/tags/urllib/">urllib</a>, <a href="/recipes/tags/urllib2/">urllib2</a>, <a href="/recipes/tags/urlopen/">urlopen</a>). </p> <p>Garbs files from the web using multithreading in an attempt to enhance transfer rate.</p> Novel JavaScript Text Compressor (JavaScript) 2011-01-31T15:41:36-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577557-novel-javascript-text-compressor/ <p style="color: grey"> JavaScript recipe 577557 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/compression/">compression</a>, <a href="/recipes/tags/encode/">encode</a>, <a href="/recipes/tags/encryption/">encryption</a>). </p> <p>Compression, encryption, and data codecs are all related fields that most programmers will use ready-made solutions for. This recipe is a shallow adventure into the writing of original code and algorithms that explores a combination of those topics. Based on the work of <a href="http://code.activestate.com/recipes/577433/">recipe 577433</a>, the code here is compliant with JavaScript and will run a test of itself when executed. From the program's report, one can gather that the novel procedures compress the source and accurately decompress it again. For those who wish to experiment further with the concept, note that fewer unique characters will yield higher compression ratios.</p> <p>To get a copy of <em>biginteger.js</em> for the program to run and compression algorithm to operator, please go to <a href="http://silentmatt.com/biginteger/" rel="nofollow">http://silentmatt.com/biginteger/</a> and use the latest version of Matthew Crumley's excellent JavaScript big integer library.</p> Thread pool (grows on demand) (Python) 2009-11-03T02:28:12-08:00Pepe Aracilhttp://code.activestate.com/recipes/users/4171769/http://code.activestate.com/recipes/576910-thread-pool-grows-on-demand/ <p style="color: grey"> Python recipe 576910 by <a href="/recipes/users/4171769/">Pepe Aracil</a> (<a href="/recipes/tags/threading/">threading</a>, <a href="/recipes/tags/threads/">threads</a>, <a href="/recipes/tags/thread_pool/">thread_pool</a>). Revision 3. </p> <p>Thread pool that grows on demand.</p> Convert Wordpress Export File to multiple html files (Python) 2008-03-24T04:57:36-07:00Luiss Reihttp://code.activestate.com/recipes/users/4136205/http://code.activestate.com/recipes/551792-convert-wordpress-export-file-to-multiple-html-fil/ <p style="color: grey"> Python recipe 551792 by <a href="/recipes/users/4136205/">Luiss Rei</a> (<a href="/recipes/tags/xml/">xml</a>). </p> <p>Converts Wordpress Export Files (XML) to multiple html files and optionally uses tags and authors to create a directory structure.</p> pyArchive (Python) 2004-12-13T11:16:36-08:00Charles Nicholshttp://code.activestate.com/recipes/users/818943/http://code.activestate.com/recipes/358412-pyarchive/ <p style="color: grey"> Python recipe 358412 by <a href="/recipes/users/818943/">Charles Nichols</a> (<a href="/recipes/tags/programs/">programs</a>). </p> <p>Windows backup utility, with remote copy, and auto cleanup. Uses zip libs. Used in a production network environment and works very well dumping both target files and remote target files over the network so you are not limited to saving a copy local.</p> Observer pattern for scalar attributes. (Python) 2004-10-02T14:43:42-07:00Bernhard Mulderhttp://code.activestate.com/recipes/users/189076/http://code.activestate.com/recipes/306865-observer-pattern-for-scalar-attributes/ <p style="color: grey"> Python recipe 306865 by <a href="/recipes/users/189076/">Bernhard Mulder</a> . </p> <p>This recipe uses descriptors of new style classes to implement the observer pattern. This implementation supports exactly one observer (no one-many relation).</p> <p>This recipe builds on recipe <a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/306864" rel="nofollow">http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/306864</a>. It assumes that the text of the recipe is stored as "list_dict_observer.py".</p> Optimising Regression Testing on COmpute Farms (Python) 2004-04-25T18:53:23-07:00Paddy McCarthyhttp://code.activestate.com/recipes/users/398009/http://code.activestate.com/recipes/280030-optimising-regression-testing-on-compute-farms/ <p style="color: grey"> Python recipe 280030 by <a href="/recipes/users/398009/">Paddy McCarthy</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). Revision 2. </p> <p>Collects statistics on different algorithms for grouping thousands of tests for execution on a compute farm where you are limited to much less job slots, (tens).</p> hexify (Python) 2001-11-05T18:51:51-08:00Robin Parmarhttp://code.activestate.com/recipes/users/99666/http://code.activestate.com/recipes/82748-hexify/ <p style="color: grey"> Python recipe 82748 by <a href="/recipes/users/99666/">Robin Parmar</a> (<a href="/recipes/tags/files/">files</a>). Revision 4. </p> <p>Hexify is a hex dump utility handy for viewing binary files at the command-prompt.</p>