Popular recipes tagged "meta:loc=138"http://code.activestate.com/recipes/tags/meta:loc=138/2017-04-16T16:48:22-07:00ActiveState Code RecipesMetro Listbox (Python)
2017-04-16T16:48:22-07:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/580785-metro-listbox/
<p style="color: grey">
Python
recipe 580785
by <a href="/recipes/users/4189907/">Miguel Martínez López</a>
(<a href="/recipes/tags/listbox/">listbox</a>, <a href="/recipes/tags/metro/">metro</a>, <a href="/recipes/tags/tkinter/">tkinter</a>).
Revision 2.
</p>
<p>I provide an alternative listbox for tkinter.</p>
<p>Using this trick you can add horizontal and vertical padding to every item and also a width.</p>
DBF reader and writer -- selective fields and nullreplace (Python)
2016-09-18T20:39:20-07:00Tomas Nordinhttp://code.activestate.com/recipes/users/4189558/http://code.activestate.com/recipes/580696-dbf-reader-and-writer-selective-fields-and-nullrep/
<p style="color: grey">
Python
recipe 580696
by <a href="/recipes/users/4189558/">Tomas Nordin</a>
(<a href="/recipes/tags/database/">database</a>).
</p>
<p>This fork assumes a desire for limited selection of field names. With
huge files this might be necessary on some machines.</p>
<p>Also, assuming that the meaning of null in a dbf file means zero might
be a mistake, so the fork adds an argument nullreplace as way to
choose what to replace null with. Null is sometimes used to mean
missing value. This change is decoupled from the selective names
feature.</p>
Simple Web socket client implementation using Tornado framework. (Python)
2015-06-30T03:37:19-07:00Vovanhttp://code.activestate.com/recipes/users/4192447/http://code.activestate.com/recipes/579076-simple-web-socket-client-implementation-using-torn/
<p style="color: grey">
Python
recipe 579076
by <a href="/recipes/users/4192447/">Vovan</a>
(<a href="/recipes/tags/client/">client</a>, <a href="/recipes/tags/tornado/">tornado</a>, <a href="/recipes/tags/web/">web</a>, <a href="/recipes/tags/websocket/">websocket</a>, <a href="/recipes/tags/websockets/">websockets</a>).
</p>
<p>Simple Web socket client implementation using Tornado framework.</p>
Monitor Progress of File Descriptors of Another Process (Python)
2014-05-30T01:10:53-07:00Alfehttp://code.activestate.com/recipes/users/4182236/http://code.activestate.com/recipes/578882-monitor-progress-of-file-descriptors-of-another-pr/
<p style="color: grey">
Python
recipe 578882
by <a href="/recipes/users/4182236/">Alfe</a>
(<a href="/recipes/tags/file_descriptor/">file_descriptor</a>, <a href="/recipes/tags/monitor/">monitor</a>, <a href="/recipes/tags/prediction/">prediction</a>, <a href="/recipes/tags/proc/">proc</a>, <a href="/recipes/tags/process/">process</a>, <a href="/recipes/tags/progress/">progress</a>, <a href="/recipes/tags/watch/">watch</a>).
</p>
<p>This tool (inspired by azat@stackoverflow, see <a href="http://stackoverflow.com/a/16082562/1281485" rel="nofollow">http://stackoverflow.com/a/16082562/1281485</a>) allows to watch the progress of the file descriptors of another process. This can be used, for example, if you transfer a file to another host and the transferring program does not show any progress indication itself. Instead of waiting blindly until the routine is done, with this tool you can use Linux's proc file system to monitor the progress of the other process while it walks through the file.</p>
<p>The tool continuously monitors the position in and the size of the files the given process's file descriptors point to. For growing (or shrinking, but that's very unusual) files, a time when it was (or will be) empty is computed ("emptyTime"), for moving file descriptors (the typical case), the time when it started at position 0 ("startTime"), the time when it will reach the current size of the file ("reachTime") and when it will meet with the end of a growing (or shrinking) file is computed ("meetTime").</p>
<p>For fixed-size files the meetTime will be the same as the reachTime of course. The meetTime only makes sense in case a file is growing and at the same time read (e. g. when a movie is downloaded to a file by one process and converted by a different process; using this tool can tell you when the converter process might run dry on the input because the download wasn't fast enough, and in this case you maybe can pause the converter to prevent this situation).</p>
<p>The tool is designed as a library; the display of the information is independent from the gathering of the data. Please feel free to create more fancy displays, add percentage output etc.</p>
2 very basic text games. (Python)
2013-07-09T03:08:47-07:00jayhttp://code.activestate.com/recipes/users/4186699/http://code.activestate.com/recipes/578596-2-very-basic-text-games/
<p style="color: grey">
Python
recipe 578596
by <a href="/recipes/users/4186699/">jay</a>
(<a href="/recipes/tags/beginner/">beginner</a>, <a href="/recipes/tags/commandline/">commandline</a>, <a href="/recipes/tags/fun/">fun</a>, <a href="/recipes/tags/python3/">python3</a>).
</p>
<p>my versions of two games found in Al Sweigart's book "invent with python"</p>
A DEMO To Show How To Expand A Standard Python Terminal On The Fly... (Python)
2012-12-17T12:47:14-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578383-a-demo-to-show-how-to-expand-a-standard-python-ter/
<p style="color: grey">
Python
recipe 578383
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/campimeter/">campimeter</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/size/">size</a>, <a href="/recipes/tags/terminal/">terminal</a>, <a href="/recipes/tags/window/">window</a>).
</p>
<p>This code shows how to open up a default Terminal running Python to tha maximum allowed on the _desktop_. I decided on writing code to do a crude emulation of a Campimeter. Anyone who has worn spectacles for a long time has had this test done at the optician's. Originally written for a Macbook Pro, OSX 10.7.5 but also tested on Debian Linux 6.0.x. READ the code for more information!!! This code WILL alter the size of the Terminal window AND changes the colours too, although it is very easy to return back to the default state it is NOT included in the code... I EXPECT professionals to know how to doo that.</p>
<p>Before running Python inside the Terminal ensure the Terminal window is at the uppermost left hand corner of your desktop...</p>
<p>I needed the maximised Python Terminal for something else but this was the easiest way to demonstrate ho to do it through Python...</p>
<p>Written so that kids can understand what is going on...</p>
<p>Enjoy finding simple solutions to often very difficult problems... ;o)</p>
<p>Bazza, G0LCU...</p>
WebSocket interface (Python)
2012-11-25T16:52:21-08:00Nick Farohttp://code.activestate.com/recipes/users/4184363/http://code.activestate.com/recipes/578348-websocket-interface/
<p style="color: grey">
Python
recipe 578348
by <a href="/recipes/users/4184363/">Nick Faro</a>
(<a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/socket/">socket</a>, <a href="/recipes/tags/websocket/">websocket</a>).
Revision 2.
</p>
<p>This tries its best to be a replacement for the regular <code>socket</code> module.</p>
<p>It supports only sending and receiving but should be useful enough.</p>
<p>The only real difference should be that you can't specify the number of bytes is received, instead do</p>
<pre class="prettyprint"><code>for message in socket.recv():
print(message)
</code></pre>
<p>Revision 2:
Added proper message receiving. Previously it just requested a ton of data. Now it reads 2 bytes, determines the length, then requests that much.</p>
Text Model (Python)
2015-01-13T22:56:53-08:00Chris Eckerhttp://code.activestate.com/recipes/users/4180203/http://code.activestate.com/recipes/577978-text-model/
<p style="color: grey">
Python
recipe 577978
by <a href="/recipes/users/4180203/">Chris Ecker</a>
(<a href="/recipes/tags/datastuctures/">datastuctures</a>, <a href="/recipes/tags/text_processing/">text_processing</a>, <a href="/recipes/tags/tree/">tree</a>).
Revision 3.
</p>
<p>A tree data type holding text data together with styling information. </p>
Post to Pastebin.com (JavaScript)
2011-04-05T21:43:24-07:00Peter Galibahttp://code.activestate.com/recipes/users/4169458/http://code.activestate.com/recipes/577634-post-to-pastebincom/
<p style="color: grey">
JavaScript
recipe 577634
by <a href="/recipes/users/4169458/">Peter Galiba</a>
(<a href="/recipes/tags/pastebin/">pastebin</a>).
</p>
<p>The newest iteration of <a href="http://code.activestate.com/recipes/577489-post-code-to-pastebincom/?in=lang-javascript">#577489</a> to post content to <a href="http://pastebin.com" rel="nofollow">pastebin.com</a>. Please change the <code>subdomain</code> variable</p>
fcntl.flock() (Unix file lock) behaviour sampling script (Python)
2010-09-22T00:11:12-07:00Jan Kaliszewskihttp://code.activestate.com/recipes/users/4172762/http://code.activestate.com/recipes/577404-fcntlflock-unix-file-lock-behaviour-sampling-scrip/
<p style="color: grey">
Python
recipe 577404
by <a href="/recipes/users/4172762/">Jan Kaliszewski</a>
(<a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/file_descriptor/">file_descriptor</a>, <a href="/recipes/tags/file_lock/">file_lock</a>, <a href="/recipes/tags/flock/">flock</a>, <a href="/recipes/tags/process/">process</a>, <a href="/recipes/tags/thread/">thread</a>).
Revision 3.
</p>
<p>A quick <em>fcntl.flock(fcntl.LOCK_EX | fcntl.LOCK_NB)</em> call sampling script: with <em>one file object</em> (and descriptor) or <em>separate file objects</em> (and different descriptors) pointing to the same filesystem path -- with/without <strong>threading</strong> or <strong>forking</strong>.</p>
<p>It's rather exemplum-and-educational piece of code than utility-script, unless somebody has to few slots in their memory to remember that <strong>flock</strong> is file-descriptor-tacked (then quick run of the script can save web-searching) :)</p>
Lazy Lists (Python)
2008-08-08T10:23:52-07:00Dan Spitzhttp://code.activestate.com/recipes/users/4166237/http://code.activestate.com/recipes/576410-lazy-lists/
<p style="color: grey">
Python
recipe 576410
by <a href="/recipes/users/4166237/">Dan Spitz</a>
(<a href="/recipes/tags/generators/">generators</a>, <a href="/recipes/tags/lazy/">lazy</a>, <a href="/recipes/tags/memoization/">memoization</a>).
Revision 6.
</p>
<p>This is a (python 3.0) recipe for LazyLists, or ordered sequences whose contents are generated lazily by an iterator.</p>
Robust Textual Tables (Python)
2007-05-06T06:25:08-07:00Richard Harrishttp://code.activestate.com/recipes/users/4050195/http://code.activestate.com/recipes/519618-robust-textual-tables/
<p style="color: grey">
Python
recipe 519618
by <a href="/recipes/users/4050195/">Richard Harris</a>
(<a href="/recipes/tags/text/">text</a>).
Revision 3.
</p>
<p>This function will display a nicely formatted textual table for you. Features include: auto-sizing of columns, auto-alignment based on column-type (which it sniffs from the first row), nicely formated centered headings, and most importantly wrapping of cells. Of course, you can manually override pretty much everything in case you don't like the defaults.</p>
A generic jython taglib for tomcat (Python)
2003-11-17T14:33:29-08:00Ferdinand Jamitzkyhttp://code.activestate.com/recipes/users/98863/http://code.activestate.com/recipes/252132-a-generic-jython-taglib-for-tomcat/
<p style="color: grey">
Python
recipe 252132
by <a href="/recipes/users/98863/">Ferdinand Jamitzky</a>
(<a href="/recipes/tags/jython/">jython</a>).
Revision 3.
</p>
<p>These java classes implement a jython taglib which can be used to embed jython code into jsp pages. It consists of two tags:
<jython:exec> ...some code... </jython:exec>
and
<jython:get var=.../>
With these two tags you can write active jython pages.</p>
PyHeartbeat - detecting inactive computers (Python)
2004-09-16T18:52:39-07:00Nicola Larosahttp://code.activestate.com/recipes/users/98137/http://code.activestate.com/recipes/52302-pyheartbeat-detecting-inactive-computers/
<p style="color: grey">
Python
recipe 52302
by <a href="/recipes/users/98137/">Nicola Larosa</a>
(<a href="/recipes/tags/network/">network</a>).
Revision 6.
</p>
<p>PyHeartbeat detects inactive computers by sending and receveing "heartbeats" as UDP packets on the network, and keeping track of how much time passed since each known computer sent its last heartbeat. The concurrency in the server is implemented using threads first, and then again using the Twisted Matrix framework.</p>