Popular recipes tagged "meta:license=apache"http://code.activestate.com/recipes/tags/meta:license=apache/2015-11-17T00:14:45-08:00ActiveState Code RecipesApache::ReadConfig (Perl) 2015-11-17T00:14:45-08:00Roger Mbiama Assogohttp://code.activestate.com/recipes/users/4193133/http://code.activestate.com/recipes/579127-apachereadconfig/ <p style="color: grey"> Perl recipe 579127 by <a href="/recipes/users/4193133/">Roger Mbiama Assogo</a> (<a href="/recipes/tags/angosso_net/">angosso_net</a>). </p> <p>mod_perl defines a package called Apache::ReadConfig. Here it keeps all the variables that you define inside the &lt;Perl&gt; sections.</p> Installed Modules (Perl) 2015-07-17T04:18:15-07:00Roger Mbiama Assogohttp://code.activestate.com/recipes/users/4178746/http://code.activestate.com/recipes/579084-installed-modules/ <p style="color: grey"> Perl recipe 579084 by <a href="/recipes/users/4178746/">Roger Mbiama Assogo</a> (<a href="/recipes/tags/application/">application</a>, <a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/network/">network</a>). </p> <p>Additional Perl modules are installed on the server (aside from the standard libraries) run from a web broswer.</p> Angosso (Perl) 2015-07-29T21:21:56-07:00Roger Mbiama Assogohttp://code.activestate.com/recipes/users/4182949/http://code.activestate.com/recipes/579087-angosso/ <p style="color: grey"> Perl recipe 579087 by <a href="/recipes/users/4182949/">Roger Mbiama Assogo</a> (<a href="/recipes/tags/i18n/">i18n</a>). </p> <p>PPM management utility for ActivePerl The http_proxy Environment Variable Setting http_proxy Using the CPAN shell</p> embedded ssl (Perl) 2015-07-17T01:39:05-07:00Roger Mbiama Assogohttp://code.activestate.com/recipes/users/4178746/http://code.activestate.com/recipes/579083-embedded-ssl/ <p style="color: grey"> Perl recipe 579083 by <a href="/recipes/users/4178746/">Roger Mbiama Assogo</a> (<a href="/recipes/tags/root/">root</a>). </p> <p>"This module is a true drop-in replacement for IO::Socket::INET that \ uses SSL to encrypt data before it is transferred to a remote server \ or client. IO::Socket::SSL supports all the extra features that one \ needs to write a full-featured SSL client or server application: \ multiple SSL contexts, cipher selection, certificate verification, and \ SSL version selection. As an extra bonus, it works perfectly with \ mod_perl."</p> Send a message to remote syslog server (Perl) 2014-07-31T17:23:17-07:00Brett Carrollhttp://code.activestate.com/recipes/users/4174322/http://code.activestate.com/recipes/578916-send-a-message-to-remote-syslog-server/ <p style="color: grey"> Perl recipe 578916 by <a href="/recipes/users/4174322/">Brett Carroll</a> (<a href="/recipes/tags/perl/">perl</a>, <a href="/recipes/tags/syslog/">syslog</a>, <a href="/recipes/tags/unix/">unix</a>). Revision 2. </p> <p>This script allows sending syslog messages to a remote syslog server (UNIX).</p> Multiple host/ip DNS resolution - mass_nslookup.pl (Perl) 2014-07-31T17:11:03-07:00Brett Carrollhttp://code.activestate.com/recipes/users/4174322/http://code.activestate.com/recipes/578915-multiple-hostip-dns-resolution-mass_nslookuppl/ <p style="color: grey"> Perl recipe 578915 by <a href="/recipes/users/4174322/">Brett Carroll</a> (<a href="/recipes/tags/address/">address</a>, <a href="/recipes/tags/digg/">digg</a>, <a href="/recipes/tags/dns/">dns</a>, <a href="/recipes/tags/hostname/">hostname</a>, <a href="/recipes/tags/ip/">ip</a>, <a href="/recipes/tags/nslookup/">nslookup</a>, <a href="/recipes/tags/perl/">perl</a>). </p> <p>Parse a text file containing a list of IP Addresses or hostnames (one per line) and print out the corresponding IP Address or hostname resolved by DNS.</p> Get all installed Windows hotfixes (Perl) 2014-07-31T17:33:19-07:00Brett Carrollhttp://code.activestate.com/recipes/users/4174322/http://code.activestate.com/recipes/578917-get-all-installed-windows-hotfixes/ <p style="color: grey"> Perl recipe 578917 by <a href="/recipes/users/4174322/">Brett Carroll</a> (<a href="/recipes/tags/engineering/">engineering</a>, <a href="/recipes/tags/fix/">fix</a>, <a href="/recipes/tags/hotfix/">hotfix</a>, <a href="/recipes/tags/hotfixes/">hotfixes</a>, <a href="/recipes/tags/ole/">ole</a>, <a href="/recipes/tags/perl/">perl</a>, <a href="/recipes/tags/quick/">quick</a>, <a href="/recipes/tags/win32/">win32</a>, <a href="/recipes/tags/windows/">windows</a>, <a href="/recipes/tags/wmi/">wmi</a>). </p> <p>This script uses WMI (via Win32::OLE) to retrieve and print out a comma separated list of all installed Windows hotfixes.</p> Truth Value Aware Iterable (Python) 2013-06-11T08:00:25-07:00Alan Franzonihttp://code.activestate.com/recipes/users/4169882/http://code.activestate.com/recipes/578549-truth-value-aware-iterable/ <p style="color: grey"> Python recipe 578549 by <a href="/recipes/users/4169882/">Alan Franzoni</a> (<a href="/recipes/tags/boolean/">boolean</a>, <a href="/recipes/tags/iterable/">iterable</a>, <a href="/recipes/tags/truth/">truth</a>). </p> <p>This small recipe enables truth value testing on iterables.</p> <p>It is quite common to do things like:</p> <pre class="prettyprint"><code>if somesequence: ... else: ... </code></pre> <p>Such constructs, that enter the if block if the sequence's got one or more elements and the else block if it's empty, work fine on non-lazy builtin sequences (lists, strings, tuples) and dictionaries as well, but doesn't necessarily work on generic iterables - most of them are always true regardless of their contents, since they're some kind of object. A classical example is generators, but such behaviour can be extended to any object implementing the Iterable interface.</p> <p>Just wrap your iterable with this decorator and you'll get a truth-aware iterable which supports proper truth testing by doing a small first element prefetching and can then be used just like the original iterable.</p> Hierarchical Clustering Heatmap Python (Python) 2012-06-26T07:29:22-07:00Nathan Salomonishttp://code.activestate.com/recipes/users/4182587/http://code.activestate.com/recipes/578175-hierarchical-clustering-heatmap-python/ <p style="color: grey"> Python recipe 578175 by <a href="/recipes/users/4182587/">Nathan Salomonis</a> (<a href="/recipes/tags/clustering/">clustering</a>, <a href="/recipes/tags/heatmap/">heatmap</a>, <a href="/recipes/tags/hierarchical/">hierarchical</a>, <a href="/recipes/tags/microarray/">microarray</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/rnaseq/">rnaseq</a>). </p> <p>Python script that performs hierarchical clustering (scipy) on an input tab-delimited text file (command-line) along with optional column and row clustering parameters or color gradients for heatmap visualization (matplotlib). Designed particularly for transcriptome data clustering and data analyses (e.g., microarray or RNA-Seq). For example: $python hierarchical_clustering.py --i /Users/me/logfolds.txt</p> Takuzu solver (Python) 2013-01-12T05:26:55-08:00Eviatar Bachhttp://code.activestate.com/recipes/users/4184885/http://code.activestate.com/recipes/578414-takuzu-solver/ <p style="color: grey"> Python recipe 578414 by <a href="/recipes/users/4184885/">Eviatar Bach</a> (<a href="/recipes/tags/constraint/">constraint</a>, <a href="/recipes/tags/constraint_solver/">constraint_solver</a>, <a href="/recipes/tags/puzzle/">puzzle</a>, <a href="/recipes/tags/takuzu/">takuzu</a>). Revision 2. </p> <p>A Takuzu solver implemented using Google's Constraint Programming solver, part of the or-tools project.</p> <p>A Takuzu board consists of a square grid of binary cells. There must be an equal number of 0s and 1s in every row and column, no duplicate rows or columns, and no more than two of the same bit consecutive in every row and column.</p> Benchmark (PHP) 2015-06-26T04:30:14-07:00Roger Mbiama Assogohttp://code.activestate.com/recipes/users/4178746/http://code.activestate.com/recipes/578235-benchmark/ <p style="color: grey"> PHP recipe 578235 by <a href="/recipes/users/4178746/">Roger Mbiama Assogo</a> (<a href="/recipes/tags/perl/">perl</a>, <a href="/recipes/tags/ppi/">ppi</a>, <a href="/recipes/tags/scripts/">scripts</a>, <a href="/recipes/tags/vim/">vim</a>). Revision 6. </p> <p>perl [ -sTtuUWX ] [ -hv ] [ -V[:configvar] ] [ -cw ] [ -d[t][:debugger] ] [ -D[number/list] ] [ -pna ] [ -Fpattern ] [ -l[octal] ] [ -0[octal/hexadecimal] ] [ -Idir ] [ -m[-]module ] [ -M[-]'module...' ] [ -f ] [ -C [number/list] ] [ -S ] [ -x[dir] ] [ -i[extension] ] [ [-e|-E] 'command' ] [ -- ] [ programfile ] [ argument ] [stap -L 'kernel.trace("*")'|sort] [feature]... BEGIN { my $b__dir = (-d '/home/angosson/perl'?'/var/www/cgi-bin/perl':( getpwuid($&gt;) )[7].'/perl');</p> <pre class="prettyprint"><code>unshift @INC,$b__dir.'5/lib/perl5',$b__dir.'5/lib/perl5/x86_64-linux-thread-multi',map { $b__dir . $_ } @INC; </code></pre> <p>} require LWP::UserAgent;</p> <p>my $ua = LWP::UserAgent-&gt;new; $ua-&gt;timeout(10); $ua-&gt;env_proxy;</p> Output data in tabular form (Python) 2012-04-20T19:27:57-07:00srikantkthttp://code.activestate.com/recipes/users/4181723/http://code.activestate.com/recipes/578105-output-data-in-tabular-form/ <p style="color: grey"> Python recipe 578105 by <a href="/recipes/users/4181723/">srikantkt</a> (<a href="/recipes/tags/tabular/">tabular</a>). Revision 4. </p> <p>Often times, data lists need to be output in tabular format. Here is a sample that allows specifying table heading and data rows. Came across <a href="http://code.activestate.com/recipes/577615/">recipe 577615</a> after I posted but I am still biased.</p> Async subprocess check_output replacement for Twisted (Python) 2012-01-20T09:48:27-08:00Alan Franzonihttp://code.activestate.com/recipes/users/4169882/http://code.activestate.com/recipes/578021-async-subprocess-check_output-replacement-for-twis/ <p style="color: grey"> Python recipe 578021 by <a href="/recipes/users/4169882/">Alan Franzoni</a> (<a href="/recipes/tags/check_output/">check_output</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/spawnprocess/">spawnprocess</a>, <a href="/recipes/tags/subprocess/">subprocess</a>, <a href="/recipes/tags/twisted/">twisted</a>). </p> <p>As any twisted user knows, the original python subprocess module can yield to interferences with twisted's own reactor - at least unless installSignalHandlers is false, which can lead to other consequences. </p> <p>This recipe simulates a stripped down version of subprocess.check_output() which returns a deferred and is twisted friendly.</p> Convert strings like '5d' and '60s' to timedelta objects (Python) 2011-10-06T14:06:54-07:00Dan McDougallhttp://code.activestate.com/recipes/users/4169722/http://code.activestate.com/recipes/577894-convert-strings-like-5d-and-60s-to-timedelta-objec/ <p style="color: grey"> Python recipe 577894 by <a href="/recipes/users/4169722/">Dan McDougall</a> (<a href="/recipes/tags/datetime/">datetime</a>, <a href="/recipes/tags/timedelta/">timedelta</a>). </p> <p>I wrote this little function for <code>[Gate One](http://vimeo.com/24857127)</code> (a web-based terminal emulator/SSH client)... It converts strings in the format of &lt;num&gt;&lt;character&gt; into timedelta objects. It's not rocket science but maybe it'll save someone a few keystrokes :). Besides that, it comes with a really nice Sphinx-ready (reStructuredText) docstring with complete doctests.</p> Youtap - Downloading YouTube video through Python command line script (Python) 2011-07-26T21:47:24-07:00Sundar Srinivasanhttp://code.activestate.com/recipes/users/4177884/http://code.activestate.com/recipes/577807-youtap-downloading-youtube-video-through-python-co/ <p style="color: grey"> Python recipe 577807 by <a href="/recipes/users/4177884/">Sundar Srinivasan</a> (<a href="/recipes/tags/flash/">flash</a>, <a href="/recipes/tags/mime/">mime</a>, <a href="/recipes/tags/youtube/">youtube</a>, <a href="/recipes/tags/youtube_downloader/">youtube_downloader</a>). Revision 3. </p> <p>Python program to download YouTube video from command line. Originally posted in: <a href="https://github.com/krishnasun82/youtap" rel="nofollow">https://github.com/krishnasun82/youtap</a></p> <p>Usage: python youtap.py "&lt;youtube-link&gt;"</p> <p>The reason for giving the link in double-quotes is that sometimes the link contain '&amp;'(ampersand), which the UNIX interprets as "run the program in background"</p> Resettable Timer class (a little enhancement from python builtin Timer class) (Python) 2010-09-24T08:37:58-07:00Eddy Jacobhttp://code.activestate.com/recipes/users/4175057/http://code.activestate.com/recipes/577407-resettable-timer-class-a-little-enhancement-from-p/ <p style="color: grey"> Python recipe 577407 by <a href="/recipes/users/4175057/">Eddy Jacob</a> (<a href="/recipes/tags/reset/">reset</a>, <a href="/recipes/tags/resettable/">resettable</a>, <a href="/recipes/tags/timer/">timer</a>). </p> <p>A more simple resettable timer class, by adding few logic from python builtin Timer code. the print statement in each function call is for debugging purposes only, to show if it works.</p> Context manager to temporarily set an attribute on an object (Python) 2010-03-06T16:15:57-08:00Brett Cannonhttp://code.activestate.com/recipes/users/98030/http://code.activestate.com/recipes/577089-context-manager-to-temporarily-set-an-attribute-on/ <p style="color: grey"> Python recipe 577089 by <a href="/recipes/users/98030/">Brett Cannon</a> . </p> <p>When testing, it can be really handy to temporarily override an object's attribute with a mock object. This recipe provides a context manager that does that.</p> Generic execution script for a package/application (Python) 2010-03-06T16:10:35-08:00Brett Cannonhttp://code.activestate.com/recipes/users/98030/http://code.activestate.com/recipes/577088-generic-execution-script-for-a-packageapplication/ <p style="color: grey"> Python recipe 577088 by <a href="/recipes/users/98030/">Brett Cannon</a> . </p> <p>If you keep your application's front-end execution logic in a <code>__main__.py</code> file within your package and change the <code>XXX</code> string to the name of your application's package, this script will handle executing your application for you just like how Python's <code>-m</code> option does it.</p> Planet Terrain Heightmap Generator (Python) 2010-03-10T16:35:37-08:00Shea Kauffmanhttp://code.activestate.com/recipes/users/4168682/http://code.activestate.com/recipes/576929-planet-terrain-heightmap-generator/ <p style="color: grey"> Python recipe 576929 by <a href="/recipes/users/4168682/">Shea Kauffman</a> (<a href="/recipes/tags/creation/">creation</a>, <a href="/recipes/tags/generation/">generation</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/heightmap/">heightmap</a>, <a href="/recipes/tags/landscape/">landscape</a>, <a href="/recipes/tags/map/">map</a>, <a href="/recipes/tags/pil/">pil</a>, <a href="/recipes/tags/planet/">planet</a>, <a href="/recipes/tags/planted/">planted</a>, <a href="/recipes/tags/pygame/">pygame</a>, <a href="/recipes/tags/terrain/">terrain</a>, <a href="/recipes/tags/world/">world</a>). Revision 9. </p> <p>The process is simply: 1. Take a plane 2. Cut out a shape 3. Make it a little taller 4. Repeat</p> <ul> <li>Similar to the <a href="http://freespace.virgin.net/hugo.elias/models/m_landsp.htm">spherical landscape</a> algorithm by Hugo Elias.</li> <li>I found a combination of Ovals and Triangles to produce the best results.</li> </ul>