Popular recipes tagged "meta:loc=84"http://code.activestate.com/recipes/tags/meta:loc=84/2016-06-15T06:42:00-07:00ActiveState Code RecipesGet text length - Column left center and right alignement (Batch)
2016-06-15T06:42:00-07:00Antoni Gualhttp://code.activestate.com/recipes/users/4182514/http://code.activestate.com/recipes/580682-get-text-length-column-left-center-and-right-align/
<p style="color: grey">
Batch
recipe 580682
by <a href="/recipes/users/4182514/">Antoni Gual</a>
.
</p>
<p>The recipe parses some lines of text (separator=$), calculates the width of each column and prints the text in columns with lefr, right and center alignment. I have put the strlen and the alignment routines in separate procedures, to ease the reuse. The alignement procedures work in place, the result is returned in the same variable as the original string.</p>
Colo(u)rs Inside Text Mode Python... (Python)
2012-08-21T21:01:57-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578101-colours-inside-text-mode-python/
<p style="color: grey">
Python
recipe 578101
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/amiga/">amiga</a>, <a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/color/">color</a>, <a href="/recipes/tags/colour/">colour</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/display/">display</a>, <a href="/recipes/tags/e_uae/">e_uae</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/windows/">windows</a>, <a href="/recipes/tags/winuae/">winuae</a>).
Revision 2.
</p>
<p>A simple DEMO to show how to enhance Python inside a Terminal. This works on Classic AMIGAs, E-UAE,
Debian Linux 6.0.0, PCLinuxOS 2009, Windows XP and Vista and WinUAE, from Python 1.4.0 to 3.3A2.</p>
<p>Due to a complaint about my _fun_ upload recently I decided to post this so that the MANY can now
find out how to manipulate text inside a Python Terminal window so that it looks much better.</p>
<p>Read the code for more information...</p>
<p>Enjoy finding simple solutions to often very difficult problems...</p>
<p>Bazza...</p>
Odd-Even Recursion (Python)
2009-06-27T05:10:15-07:00Fouad Teniouhttp://code.activestate.com/recipes/users/4155345/http://code.activestate.com/recipes/576747-odd-even-recursion/
<p style="color: grey">
Python
recipe 576747
by <a href="/recipes/users/4155345/">Fouad Teniou</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>).
Revision 6.
</p>
<p>Odd-Even Recursion program is a recursive function, which does produce a positive or a negative set of odd or even numbers. However, the function return numbers which are lower or greater than the value of the number entered by the user until it reaches its base case value, where the function returns a value and the recursion stops. Though solving repetitive problems requires a powerful method and yet recursion allows the design of faster recursive algorithms. Recursion method could be used to solve higher-level mathematics' problems, such as sequences and it is a branch in the computer science study.</p>
XML to Python data structure (Python)
2009-05-31T16:10:38-07:00Wai Yip Tunghttp://code.activestate.com/recipes/users/2382677/http://code.activestate.com/recipes/534109-xml-to-python-data-structure/
<p style="color: grey">
Python
recipe 534109
by <a href="/recipes/users/2382677/">Wai Yip Tung</a>
(<a href="/recipes/tags/xml/">xml</a>).
Revision 8.
</p>
<p>This simple method construct Python data structure from XML in one simple step. Data is accessed using the Pythonic "object.attribute" notation. See the discussion below for usage examples.</p>
Module For Running Simple Proxies (Python)
2007-02-01T21:51:53-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/502204-module-for-running-simple-proxies/
<p style="color: grey">
Python
recipe 502204
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/network/">network</a>).
</p>
<p>Proxies can be useful at times but may not be
simple to create and run. This recipe provides
a single class that can build proxy objects
capable of being both started and stopped.</p>
attrview(): dict-style access to attributes (Python)
2007-02-21T15:49:08-08:00Greg Falconhttp://code.activestate.com/recipes/users/4034400/http://code.activestate.com/recipes/502219-attrview-dict-style-access-to-attributes/
<p style="color: grey">
Python
recipe 502219
by <a href="/recipes/users/4034400/">Greg Falcon</a>
.
Revision 2.
</p>
<p>This class wraps any object, and allows accessing and modifying that object's properties using the dict interface. This wrapper is meant to provide a clean interface to getattr/setattr/hasattr/delattr.</p>
SMTP Mailsink (Python)
2005-10-11T11:00:32-07:00Adam Feuerhttp://code.activestate.com/recipes/users/2512995/http://code.activestate.com/recipes/440690-smtp-mailsink/
<p style="color: grey">
Python
recipe 440690
by <a href="/recipes/users/2512995/">Adam Feuer</a>
(<a href="/recipes/tags/network/">network</a>).
</p>
<p>This little class starts up an SMTP server which acts as an email sink, collecting all received emails destined for any address. All emails are routed to a Portable Unix Mailbox file. This is very handy for testing applications that send email. It runs in its own thread, so you can easily use it from a test fixture to collect your emails and verify them for correctness.</p>
Detect character encoding in an XML file (Python)
2005-01-20T00:50:37-08:00Lars Tiedehttp://code.activestate.com/recipes/users/2270421/http://code.activestate.com/recipes/363841-detect-character-encoding-in-an-xml-file/
<p style="color: grey">
Python
recipe 363841
by <a href="/recipes/users/2270421/">Lars Tiede</a>
(<a href="/recipes/tags/xml/">xml</a>).
Revision 2.
</p>
<p>A function analyzing an open xml file for its character encoding by
- checking for a unicode BOM or (on failure)
- searching the xml declaration at the beginning of the file for the "encoding" attribute</p>
Constructing DAGs to Avoid Redundancy in Trees (Python)
2004-09-04T09:46:20-07:00Aaron Leunghttp://code.activestate.com/recipes/users/2006476/http://code.activestate.com/recipes/303415-constructing-dags-to-avoid-redundancy-in-trees/
<p style="color: grey">
Python
recipe 303415
by <a href="/recipes/users/2006476/">Aaron Leung</a>
(<a href="/recipes/tags/oop/">oop</a>).
Revision 2.
</p>
<p>An example showing how Python's features can be used to optimize the construction of tree-like data structures in order to produce directed acyclic graphs (DAGs) instead.</p>
Case Insensitive Sort (Python)
2004-07-07T06:09:12-07:00Michael Foordhttp://code.activestate.com/recipes/users/1565518/http://code.activestate.com/recipes/286204-case-insensitive-sort/
<p style="color: grey">
Python
recipe 286204
by <a href="/recipes/users/1565518/">Michael Foord</a>
.
</p>
<p>This is a recipe that does a case insensitive sort. The normal sort methods of lists has 'B'<'a', which means that it would sort 'Pear' to come before 'apple' in a list. You can pass in a function to the sort method to change this... but this can be slow. This is a function that transforms the list, uses the sort method and then transforms it back.</p>
HTTP Based Network Check for Windows boxes. (Python)
2008-08-09T16:06:49-07:00Magnus Lyckåhttp://code.activestate.com/recipes/users/729822/http://code.activestate.com/recipes/203612-http-based-network-check-for-windows-boxes/
<p style="color: grey">
Python
recipe 203612
by <a href="/recipes/users/729822/">Magnus Lyckå</a>
(<a href="/recipes/tags/network/">network</a>).
Revision 2.
</p>
<p>A demonstration of how the Python HTTP server classes can be used.</p>
Date difference (Python)
2002-02-20T13:19:10-08:00Nelson Rushhttp://code.activestate.com/recipes/users/144881/http://code.activestate.com/recipes/115421-date-difference/
<p style="color: grey">
Python
recipe 115421
by <a href="/recipes/users/144881/">Nelson Rush</a>
.
</p>
<p>Finds the number of days between two dates.</p>
IMAP mailwatcher program using Tkinter (Python)
2001-03-22T20:35:29-08:00Brent Burleyhttp://code.activestate.com/recipes/users/98036/http://code.activestate.com/recipes/52299-imap-mailwatcher-program-using-tkinter/
<p style="color: grey">
Python
recipe 52299
by <a href="/recipes/users/98036/">Brent Burley</a>
(<a href="/recipes/tags/network/">network</a>).
</p>
<p>Polls an IMAP inbox for unread messages and displays the sender
and subject in a scrollable window using Tkinter.</p>
<p>Reads servername, user, and password from ~/.imap file. They must be
on one line, separated with spaces.</p>