Popular recipes tagged "meta:loc=92"http://code.activestate.com/recipes/tags/meta:loc=92/2015-10-07T18:02:46-07:00ActiveState Code RecipesGenerate a PDF invoice with xtopdf and Python (Python)
2015-10-07T18:02:46-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/579108-generate-a-pdf-invoice-with-xtopdf-and-python/
<p style="color: grey">
Python
recipe 579108
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/pdf_generation/">pdf_generation</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/python2/">python2</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>).
</p>
<p>This recipe shows the basics of how to generate invoices as PDF documents, using xtopdf, a Python toolkit for PDF creation. An example of creating a simple invoice through Python and xtopdf code is shown. </p>
<p>xtopdf is available on Bitbucket at:</p>
<p><a href="https://bitbucket.org/vasudevram/xtopdf" rel="nofollow">https://bitbucket.org/vasudevram/xtopdf</a></p>
<p>and you can find many links with examples of using xtopdf, how to install it, etc., from this Google search:</p>
<p><a href="https://google.com/search?q=xtopdf" rel="nofollow">https://google.com/search?q=xtopdf</a></p>
<p>This sub-feed of my blog:</p>
<p><a href="http://jugad2.blogspot.com/search/label/xtopdf" rel="nofollow">http://jugad2.blogspot.com/search/label/xtopdf</a></p>
<p>gives access to all my blog posts labelled xtopdf.</p>
Simple Finite State Machine class (Python)
2012-11-20T14:37:34-08:00Tony Fluryhttp://code.activestate.com/recipes/users/4184150/http://code.activestate.com/recipes/578332-simple-finite-state-machine-class/
<p style="color: grey">
Python
recipe 578332
by <a href="/recipes/users/4184150/">Tony Flury</a>
(<a href="/recipes/tags/automation/">automation</a>, <a href="/recipes/tags/finitestatemachine/">finitestatemachine</a>, <a href="/recipes/tags/tokeniser/">tokeniser</a>).
</p>
<p>This may not be useful to many people, but this is a very simple finite state machine. It is defined as a class so that you can have multiple state machines running at the same time - all with different state/transition lists.</p>
KYSU (Keep Your Stuff Updated) (Python)
2012-07-29T01:12:01-07:00Gamoholichttp://code.activestate.com/recipes/users/4182585/http://code.activestate.com/recipes/578174-kysu-keep-your-stuff-updated/
<p style="color: grey">
Python
recipe 578174
by <a href="/recipes/users/4182585/">Gamoholic</a>
(<a href="/recipes/tags/automatic/">automatic</a>, <a href="/recipes/tags/exe/">exe</a>, <a href="/recipes/tags/installer/">installer</a>, <a href="/recipes/tags/updated/">updated</a>, <a href="/recipes/tags/updater/">updater</a>).
Revision 5.
</p>
<p>I wrote this program to keep my Samba share up to date. The Samba share contains installers for the programs that I use to fix and update computers (ccleaner, mbam, java, .etc). It can also be used for ISO's such as clonezilla.</p>
<p>For the latest version of the script and the accompanying files please go to GitHub.</p>
<p><a href="https://github.com/Gamoholic/KYSU" rel="nofollow">https://github.com/Gamoholic/KYSU</a></p>
<p>!!! Important! The only OS I have tested this on is Ubuntu. I will test Windows soon. If it doesn't work on any other OS please let me know! Also, I have no idea how well this works with Python 3. I may test that eventually.</p>
Simple Morse Code Practice Oscillator. (Python)
2012-01-09T22:49:05-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578010-simple-morse-code-practice-oscillator/
<p style="color: grey">
Python
recipe 578010
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/morse/">morse</a>, <a href="/recipes/tags/morse_code/">morse_code</a>, <a href="/recipes/tags/morse_practice_oscillator/">morse_practice_oscillator</a>, <a href="/recipes/tags/sound/">sound</a>).
Revision 2.
</p>
<p>This is not for the big guns, but for the Amateur coder AND radio enthusiast.</p>
<p>It is a DEMO Morse Code Practice Oscillator that will allow the user to practice
sending Morse code using the "o" and "p" keys as a PSEUDO-paddle key. It is set to
around 8 WPM, (Words Per Minute). The code allows "O" and "P" to be used at around
12 WPM, when "Caps Lock" is turned on. Read the code for more informtion.</p>
<p>It is for at least standard text mode Python 2.5.2 to 2.7.2 using PCLinuxOS 2009 and
Debian 6.0.0. It may well work at a much earlier version. I do have a version for
Python 3.x.x but that will be uploaded elsewhere.</p>
<p>It is written in such a way that youngsters can understand what is going on.</p>
<p>Enjoy finding simple solutions to often very difficult problems... ;o)</p>
<p>Bazza, G0LCU...</p>
Line-based side-by-side diff (Python)
2011-07-10T20:38:23-07:00Christoph Burgmerhttp://code.activestate.com/recipes/users/4178578/http://code.activestate.com/recipes/577784-line-based-side-by-side-diff/
<p style="color: grey">
Python
recipe 577784
by <a href="/recipes/users/4178578/">Christoph Burgmer</a>
(<a href="/recipes/tags/diff/">diff</a>).
</p>
<p>A line-based diff that shows two versions side-by-side based on Google's diff_match_patch implementation.</p>
<p>Deletions are displayed on the left side, while additions are displayed on the right similar to the diff shown on Wikipedia.</p>
Decorator for writing polymorphic functions (Python)
2010-09-21T06:08:48-07:00Baptiste Carvellohttp://code.activestate.com/recipes/users/4175002/http://code.activestate.com/recipes/577393-decorator-for-writing-polymorphic-functions/
<p style="color: grey">
Python
recipe 577393
by <a href="/recipes/users/4175002/">Baptiste Carvello</a>
(<a href="/recipes/tags/polymorphism/">polymorphism</a>, <a href="/recipes/tags/unicode/">unicode</a>).
Revision 2.
</p>
<p>Python 3 makes a clean separation between unicode text strings (str) and byte
strings (bytes). However, for some tasks (notably networking), it makes sense
to apply the same process to str and bytes, usually relying on the byte string
beeing encoded with an ASCII compatible encoding.</p>
<p>In this context, a polymorphic function is one which will operate on unicode
strings (str) or bytes objects (bytes) depending on the type of the arguments.
The common difficulty is that string constants used in the function also have
to be of the right type. This decorator helps by allowing to use a different
set of constants depending on the type of the argument.</p>
Curve fitting to N random points (Java)
2010-03-26T17:21:53-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577150-curve-fitting-to-n-random-points/
<p style="color: grey">
Java
recipe 577150
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/applet/">applet</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/math/">math</a>).
</p>
<p>It creates a curve that passes through N random points using
inverse distance weighted averages.</p>
urrlib2 opener for SSL proxy (CONNECT method) (Python)
2005-11-16T15:04:54-08:00Alessandro Budaihttp://code.activestate.com/recipes/users/2668504/http://code.activestate.com/recipes/456195-urrlib2-opener-for-ssl-proxy-connect-method/
<p style="color: grey">
Python
recipe 456195
by <a href="/recipes/users/2668504/">Alessandro Budai</a>
(<a href="/recipes/tags/network/">network</a>).
Revision 2.
</p>
<p>This small module builds an urllib2 opener that can be used to make a connection through a proxy using the http CONNECT method (that can be used to proxy SSLconnections).
The current urrlib2 seems to not support this method.</p>
Twisted XML RPC server with basic HTTP authentication (Python)
2007-08-09T09:48:48-07:00Anandhttp://code.activestate.com/recipes/users/760763/http://code.activestate.com/recipes/526625-twisted-xml-rpc-server-with-basic-http-authenticat/
<p style="color: grey">
Python
recipe 526625
by <a href="/recipes/users/760763/">Anand</a>
(<a href="/recipes/tags/web/">web</a>).
Revision 3.
</p>
<p>This recipe illustrates an XML RPC server using twisted with support for HTTP basic client authentication.</p>
timehook: modify the Python interpreter time. (Python)
2007-03-07T09:05:37-08:00Manlio Perillohttp://code.activestate.com/recipes/users/2425438/http://code.activestate.com/recipes/502286-timehook-modify-the-python-interpreter-time/
<p style="color: grey">
Python
recipe 502286
by <a href="/recipes/users/2425438/">Manlio Perillo</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
</p>
<p>timehook is a simple module that allows you to modify the time clock
without having to modify the system clock.</p>
Call a Callback when a Tkinter.Text is Modified (Python)
2005-12-15T23:00:43-08:00Simon Formanhttp://code.activestate.com/recipes/users/2702520/http://code.activestate.com/recipes/464635-call-a-callback-when-a-tkintertext-is-modified/
<p style="color: grey">
Python
recipe 464635
by <a href="/recipes/users/2702520/">Simon Forman</a>
(<a href="/recipes/tags/ui/">ui</a>).
Revision 2.
</p>
<p>A Tkinter.Text can notice when its contents are changed. This recipe shows how to make use of the virtual event this generates to call your own callback.</p>
ElementTree Text Helper (Python)
2006-11-29T22:20:13-08:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/498286-elementtree-text-helper/
<p style="color: grey">
Python
recipe 498286
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/xml/">xml</a>).
Revision 4.
</p>
<p>Solves the "tail-problem" for prose-oriented XML. Recursively pulls text out of elements and their sub-elements. Extracts text from DocBook, XMHTL, and other nested XML markup.</p>
A general solution of Eight Queens (Python)
2006-03-17T16:00:28-08:00Alec Janghttp://code.activestate.com/recipes/users/2818274/http://code.activestate.com/recipes/475145-a-general-solution-of-eight-queens/
<p style="color: grey">
Python
recipe 475145
by <a href="/recipes/users/2818274/">Alec Jang</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>).
</p>
<p>This is a general method to figuren out all solutions of eight queens. Certainly, it can also solve any number of queens. It's very fast.</p>
Rebind class properties (Python)
2005-12-17T09:26:20-08:00Shekhar Tiwatnehttp://code.activestate.com/recipes/users/2071240/http://code.activestate.com/recipes/440634-rebind-class-properties/
<p style="color: grey">
Python
recipe 440634
by <a href="/recipes/users/2071240/">Shekhar Tiwatne</a>
(<a href="/recipes/tags/oop/">oop</a>).
Revision 2.
</p>
<p>Sometimes you define properties in base class and override the getter setter methods in derived classes.
Then you find out the base class though has derived properties are still pointing to baseclasse's methods not the overriden ones.</p>
tail -f for multiple log files in a given directory (Python)
2005-05-20T16:23:54-07:00Bibha Tripathihttp://code.activestate.com/recipes/users/2437311/http://code.activestate.com/recipes/414771-tail-f-for-multiple-log-files-in-a-given-directory/
<p style="color: grey">
Python
recipe 414771
by <a href="/recipes/users/2437311/">Bibha Tripathi</a>
(<a href="/recipes/tags/files/">files</a>).
Revision 2.
</p>
<p>I needed to write a Python script for a "tail -f" that displays log entries from multiple files in a given directory. The display had to be in chronological order, the first column of each log file being timestamp of the log. It should work for any type of files.</p>
<p>Usage: python tail_m.py directoryname</p>
Generating a RSS feed from CVS commits (Python)
2004-10-16T14:27:11-07:00Ori Peleghttp://code.activestate.com/recipes/users/2056315/http://code.activestate.com/recipes/310322-generating-a-rss-feed-from-cvs-commits/
<p style="color: grey">
Python
recipe 310322
by <a href="/recipes/users/2056315/">Ori Peleg</a>
.
Revision 2.
</p>
<p>Track commits to CVS repositories as RSS feeds.</p>
urllib2 for actions depending on http response codes (Python)
2004-02-07T13:34:32-08:00Lee Harrhttp://code.activestate.com/recipes/users/212718/http://code.activestate.com/recipes/267197-urllib2-for-actions-depending-on-http-response-cod/
<p style="color: grey">
Python
recipe 267197
by <a href="/recipes/users/212718/">Lee Harr</a>
(<a href="/recipes/tags/web/">web</a>).
</p>
<p>I wanted to touch a particular web page (in order to open/close a database connection inside of Zope) so I came up with this module which uses urllib2 to make the web connection</p>
<p>I was not sure what a 'realm' was, so first I made the HTTPRealmFinder to find out what the realm is.</p>
<p>The HTTPinger calls my required page and acts according to the http return code.</p>
A way to deal with checking for types (Python)
2004-09-28T11:17:30-07:00John Nielsenhttp://code.activestate.com/recipes/users/135654/http://code.activestate.com/recipes/305888-a-way-to-deal-with-checking-for-types/
<p style="color: grey">
Python
recipe 305888
by <a href="/recipes/users/135654/">John Nielsen</a>
.
Revision 6.
</p>
<p>Managing types is normally simple in python, since it does typing as late as possible during runtime. Sometimes the issues of type still rears it's head, especially among programmers used to the "type at compile time" variants.</p>
<p>You want to resist doing a naive approach like type(obj)==str, since you then ignore subclasses.</p>
<p>What this recipe does is make a distinction between objects that _are_ are certain type or it's subclass and objects that act good enough. Most of the time
the difference will not matter. If it is a certain python type or in some cases like with a sequence, possible among a few python types, it returns a 1, if it is good enough it returns a -1, and finally it returns zero if it is not good enough.</p>
<p>Good enough is enabled by checking for attributes and callables instead of explicit type and sometimes by checking for success of certain actions. In cases where it can be good enough, you simply check for just a true value which both 1 and -1 will evaluate to.</p>
<p>I put in typical checks for many things ranging from generators to lists to file handles.</p>
prompt - simple multiline interactive interpreter (Python)
2004-06-01T09:33:12-07:00Carl Kleffnerhttp://code.activestate.com/recipes/users/536075/http://code.activestate.com/recipes/285214-prompt-simple-multiline-interactive-interpreter/
<p style="color: grey">
Python
recipe 285214
by <a href="/recipes/users/536075/">Carl Kleffner</a>
(<a href="/recipes/tags/debugging/">debugging</a>).
</p>
<p>The prompt module is a simple embedded multiline python interpreter built around raw_input(). The interpreter can be started at any given location in a program by executing a tiny code object and is allways executed in the namespace of the caller. Objects in the current scope can easily be explored and modified. Intermediate interruption of the control flow for manual interaction is handy for debugging purposes. The ability of multiline commands was crucial for me, so I wrote this module. It is tested with python, jython and stackless. The prompt codeobject can also be started from the pdb prompt.</p>
Merging two sorted iterators into a single iterator (Python)
2003-04-30T23:04:43-07:00Danny Yoohttp://code.activestate.com/recipes/users/98032/http://code.activestate.com/recipes/197530-merging-two-sorted-iterators-into-a-single-iterato/
<p style="color: grey">
Python
recipe 197530
by <a href="/recipes/users/98032/">Danny Yoo</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>).
Revision 2.
</p>
<p>Provides a mergeiter() function that can merge two iterators into a single iterator. Uses generators, and guarantees constant memory use.</p>