Popular recipes tagged "meta:loc=77"http://code.activestate.com/recipes/tags/meta:loc=77/2017-03-22T13:12:25-07:00ActiveState Code RecipesHow to Maintain PDF Links with fitz / PyMuPDF (Python) 2017-03-22T13:12:25-07:00Jorj X. McKiehttp://code.activestate.com/recipes/users/4193772/http://code.activestate.com/recipes/580765-how-to-maintain-pdf-links-with-fitz-pymupdf/ <p style="color: grey"> Python recipe 580765 by <a href="/recipes/users/4193772/">Jorj X. McKie</a> (<a href="/recipes/tags/fitz/">fitz</a>, <a href="/recipes/tags/link/">link</a>, <a href="/recipes/tags/mupdf/">mupdf</a>, <a href="/recipes/tags/pdf/">pdf</a>). </p> <p>This REPL script example displays, updates, inserts and deletes links on a PDF page.</p> Functional D plus Python pipeline to generate PDF (Text) 2016-09-22T15:32:17-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580701-functional-d-plus-python-pipeline-to-generate-pdf/ <p style="color: grey"> Text recipe 580701 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/pdf_generation/">pdf_generation</a>, <a href="/recipes/tags/pipe/">pipe</a>, <a href="/recipes/tags/pipeline/">pipeline</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>This recipe is a command pipeline. The first component of the pipeline is a D language program that makes use of simple functional programming and template / generic programming features of D, to transform some input into the desired output. Both input and output are text. The D program writes the output to standard output, which is then read by a Python program that reads that as input via standard input, and converts it to PDF.</p> Split file in place into two parts (Python) 2015-02-11T20:08:35-08:00shavy89http://code.activestate.com/recipes/users/4191634/http://code.activestate.com/recipes/579025-split-file-in-place-into-two-parts/ <p style="color: grey"> Python recipe 579025 by <a href="/recipes/users/4191634/">shavy89</a> (<a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/splitting/">splitting</a>). Revision 2. </p> <p>Split file in place into two parts </p> git pre-commit hook to reject large files using Python (Python) 2015-03-10T09:36:28-07:00Albert-Jan Roskamhttp://code.activestate.com/recipes/users/4177640/http://code.activestate.com/recipes/578883-git-pre-commit-hook-to-reject-large-files-using-py/ <p style="color: grey"> Python recipe 578883 by <a href="/recipes/users/4177640/">Albert-Jan Roskam</a> (<a href="/recipes/tags/git/">git</a>, <a href="/recipes/tags/hook/">hook</a>, <a href="/recipes/tags/precommit/">precommit</a>, <a href="/recipes/tags/python/">python</a>). Revision 9. </p> <p>This script should be saved in the templatedir, so it ends up in .git/hooks whenever you do a new git init. By default, commits that contain files larger than 5 Mb are blocked. This is useful for preventing accidental large commits that are not caught by .gitignore. You can easily bypass the hook by specifing "--no-verify" with git commit. (in a previous version of this script, this did not work correctly)</p> Basic Gtk.TreeView Example with two sortable columns (Python) 2013-11-27T13:56:38-08:00Anonimistahttp://code.activestate.com/recipes/users/4188571/http://code.activestate.com/recipes/578772-basic-gtktreeview-example-with-two-sortable-column/ <p style="color: grey"> Python recipe 578772 by <a href="/recipes/users/4188571/">Anonimista</a> (<a href="/recipes/tags/gtk/">gtk</a>, <a href="/recipes/tags/user_interface/">user_interface</a>). </p> <p>Basic Gtk.TreeView Example with two sortable columns</p> Hofstadter Butterfly Fractal (Python) 2013-09-23T03:18:02-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578670-hofstadter-butterfly-fractal/ <p style="color: grey"> Python recipe 578670 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/physics/">physics</a>). Revision 2. </p> <p>Hofstadter Butterfly Fractal</p> Simple but Complex Calculator (Python) 2013-10-09T17:18:45-07:00Sean "Golden_Apples" Bambichttp://code.activestate.com/recipes/users/4187859/http://code.activestate.com/recipes/578663-simple-but-complex-calculator/ <p style="color: grey"> Python recipe 578663 by <a href="/recipes/users/4187859/">Sean "Golden_Apples" Bambic</a> . Revision 2. </p> <p>This is a calculator I created. You do not need any thing extra just run in 2.7.3 python. If you decide to change or modify this code and use it somewhere public please give me credit Sean Bambic</p> <p>Thank You</p> <p>ALL RIGHTS RESERVED 2013</p> Implementation of Knuth–Morris–Pratt algorithm (C) 2011-10-15T00:33:41-07:00Shao-chuan Wanghttp://code.activestate.com/recipes/users/4168519/http://code.activestate.com/recipes/577908-implementation-of-knuthmorrispratt-algorithm/ <p style="color: grey"> C recipe 577908 by <a href="/recipes/users/4168519/">Shao-chuan Wang</a> (<a href="/recipes/tags/kmp/">kmp</a>, <a href="/recipes/tags/matching/">matching</a>, <a href="/recipes/tags/string/">string</a>). Revision 2. </p> <p>Knuth–Morris–Pratt (KMP) is a linear time string matching algorithm.</p> <p><a href="http://en.wikipedia.org/wiki/Knuth%25E2%2580%2593Morris%25E2%2580%2593Pratt_algorithm" rel="nofollow">http://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm</a></p> <p>This recipe gives a C-version implementation.</p> 4D Mandelbrot Fractal (Python) 2012-07-07T23:42:43-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577715-4d-mandelbrot-fractal/ <p style="color: grey"> Python recipe 577715 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/pil/">pil</a>). Revision 4. </p> <p>Draws a random 2D slice from 4D Mandelbrot fractal.</p> easy logging with extras (Python) 2010-11-02T10:04:15-07:00Bud P. Brueggerhttp://code.activestate.com/recipes/users/4175472/http://code.activestate.com/recipes/577448-easy-logging-with-extras/ <p style="color: grey"> Python recipe 577448 by <a href="/recipes/users/4175472/">Bud P. Bruegger</a> (<a href="/recipes/tags/logging/">logging</a>). </p> <p>The logging package offers the "extra" keyword argument in Logger.log to add user-defined attributes to the log record. LoggerAdaptors make it easy to use extras that are constant for a given logger; then simply use logger.debug, logger.info, ecc. But this won't support variable extra arguments. </p> <p>The present recipe makes it easy to use "extra" attributes that are not constant but variables passed to the (modified) logging methods ('debug', 'info', ...)</p> Script para saber calida del aire Santiago de Chile (Python) 2011-06-02T00:55:02-07:00jrovegnohttp://code.activestate.com/recipes/users/4170207/http://code.activestate.com/recipes/577369-script-para-saber-calida-del-aire-santiago-de-chil/ <p style="color: grey"> Python recipe 577369 by <a href="/recipes/users/4170207/">jrovegno</a> (<a href="/recipes/tags/aire/">aire</a>, <a href="/recipes/tags/calidad/">calidad</a>, <a href="/recipes/tags/santiago/">santiago</a>). Revision 4. </p> <p>Script para saber calida del aire Santiago de Chile</p> Reading large files from zip archive (Python) 2009-08-17T10:24:40-07:00Volker S.http://code.activestate.com/recipes/users/4171469/http://code.activestate.com/recipes/576882-reading-large-files-from-zip-archive/ <p style="color: grey"> Python recipe 576882 by <a href="/recipes/users/4171469/">Volker S.</a> (<a href="/recipes/tags/large_files/">large_files</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/zip/">zip</a>). Revision 3. </p> <p>The standard zipfile module provides only a method to extract the entire content of a file from within a zip-file. This extension adds a generator method to iterate over the lines in a file, avoiding the memory problems.</p> BFS (breadth first search) graph traversal (Python) 2009-03-02T20:20:56-08:00mojave kidhttp://code.activestate.com/recipes/users/4169379/http://code.activestate.com/recipes/576675-bfs-breadth-first-search-graph-traversal/ <p style="color: grey"> Python recipe 576675 by <a href="/recipes/users/4169379/">mojave kid</a> (<a href="/recipes/tags/bfs/">bfs</a>, <a href="/recipes/tags/breath/">breath</a>). Revision 4. </p> <p>Guido illustrated the DFS recursive traversal of a graph (<a href="http://www.python.org/doc/essays/graphs.html" rel="nofollow">http://www.python.org/doc/essays/graphs.html</a>) However if the graph is too big, recursion error occurs.</p> <p>Here im pitching in my recipe for an iterative BFS traversal.</p> <p>Im using Guido's graph representation using dictionary.</p> Thread pool mixin class for use with SocketServer.TCPServer (Python) 2008-07-10T18:52:58-07:00Michael Palmerhttp://code.activestate.com/recipes/users/1827292/http://code.activestate.com/recipes/574454-thread-pool-mixin-class-for-use-with-socketservert/ <p style="color: grey"> Python recipe 574454 by <a href="/recipes/users/1827292/">Michael Palmer</a> (<a href="/recipes/tags/threads/">threads</a>). Revision 2. </p> <p>This is intended as a drop-in replacement for the ThreadingMixIn class in module SocketServer of the standard lib. Instead of spawning a new thread for each request, requests are processed by of pool of reusable threads.</p> Easy testing of CGI scripts (Python) 2016-11-01T02:27:13-07:00Bryan Olsonhttp://code.activestate.com/recipes/users/1998252/http://code.activestate.com/recipes/550822-easy-testing-of-cgi-scripts/ <p style="color: grey"> Python recipe 550822 by <a href="/recipes/users/1998252/">Bryan Olson</a> (<a href="/recipes/tags/cgi/">cgi</a>). Revision 3. </p> <p>Invoking 'runcgi.py target.cgi' starts a built-in web server listening on the localhost adapter, configures the server to run target.cgi as a CGI program, then launches the system's default web browser to get the URL of the target script. The CGI script need not be in Python. The terminal that launched runcgi.py will show the server's log, which reports requests, responses, and errors.</p> Add thousands separator commas to formatted numbers (Python) 2006-10-07T15:49:28-07:00Manuel Garciahttp://code.activestate.com/recipes/users/2827266/http://code.activestate.com/recipes/498181-add-thousands-separator-commas-to-formatted-number/ <p style="color: grey"> Python recipe 498181 by <a href="/recipes/users/2827266/">Manuel Garcia</a> (<a href="/recipes/tags/text/">text</a>). </p> <p>Needed formatted numbers with thousands separator commas added on an end-user report. The usual way mentioned is to use 'module locale.format', but that didn't work cleanly on my Windows machine, and the cure seemed worse than the disease.</p> EventQueue class to queue function calls (Python) 2006-07-18T13:07:03-07:00faulkner612http://code.activestate.com/recipes/users/2903960/http://code.activestate.com/recipes/496894-eventqueue-class-to-queue-function-calls/ <p style="color: grey"> Python recipe 496894 by <a href="/recipes/users/2903960/">faulkner612</a> (<a href="/recipes/tags/threads/">threads</a>). </p> <p>Synchronize/sequentialize sensitive parts of an asynchronous event solution with EventQueue. For example, sequentialize changes to a document buffer which may come from multiple threads.</p> Container (Python) 2006-05-13T07:37:50-07:00tomer filibahttp://code.activestate.com/recipes/users/2520014/http://code.activestate.com/recipes/496697-container/ <p style="color: grey"> Python recipe 496697 by <a href="/recipes/users/2520014/">tomer filiba</a> (<a href="/recipes/tags/extending/">extending</a>). </p> <p>A generic attribute container, with pretty printing and recursion protection</p> Run time linked attributes (Python) 2006-05-28T15:00:16-07:00Michael Murrhttp://code.activestate.com/recipes/users/2903981/http://code.activestate.com/recipes/496745-run-time-linked-attributes/ <p style="color: grey"> Python recipe 496745 by <a href="/recipes/users/2903981/">Michael Murr</a> . </p> <p>A metaclass that allows the runtime creation of parent references, without needing to pass them on the command line. For example:</p> <p>a.b -> (points to) b b.creator -> (points to) a</p> Import Modules/Discover methods from a directory name (Python) 2005-07-15T13:15:48-07:00Jesse Nollerhttp://code.activestate.com/recipes/users/2519072/http://code.activestate.com/recipes/436873-import-modulesdiscover-methods-from-a-directory-na/ <p style="color: grey"> Python recipe 436873 by <a href="/recipes/users/2519072/">Jesse Noller</a> (<a href="/recipes/tags/extending/">extending</a>). Revision 2. </p> <p>For something I am working on, I needed the ability to scan a supplied directory, adding the directory to the sys.path within Python, and then blanket import the modules within that directory. Following that, I had to filter any builtin or special methods within those modules and return a list of the methods for the module I had imported.</p> <p>The script is very simplistic in what it does.</p>