Popular recipes tagged "meta:loc=42"http://code.activestate.com/recipes/tags/meta:loc=42/2015-08-02T17:31:59-07:00ActiveState Code RecipesCSV to Flat File Converter (Python) 2015-08-02T17:31:59-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/579091-csv-to-flat-file-converter/ <p style="color: grey"> Python recipe 579091 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/csv/">csv</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/utility/">utility</a>). </p> <p>Converts a CSV file to a flat file (table).</p> A Simple Calculator (Tcl) 2014-09-06T13:36:35-07:00Mike Manilonehttp://code.activestate.com/recipes/users/4190728/http://code.activestate.com/recipes/578929-a-simple-calculator/ <p style="color: grey"> Tcl recipe 578929 by <a href="/recipes/users/4190728/">Mike Manilone</a> (<a href="/recipes/tags/calculator/">calculator</a>, <a href="/recipes/tags/gui/">gui</a>). </p> <p>A simple calculator. Calculation is done by [expr].</p> Perfect Square Checker (Python) 2014-09-10T02:21:27-07:00Ethan Hannhttp://code.activestate.com/recipes/users/4190746/http://code.activestate.com/recipes/578931-perfect-square-checker/ <p style="color: grey"> Python recipe 578931 by <a href="/recipes/users/4190746/">Ethan Hann</a> (<a href="/recipes/tags/check/">check</a>, <a href="/recipes/tags/checker/">checker</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/root/">root</a>, <a href="/recipes/tags/square/">square</a>). </p> <p>This program will take input from the user and either check if a number is a perfect square or square a number, depending on user's choice.</p> Random Spiral Fractals (Python) 2013-09-29T05:35:20-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578658-random-spiral-fractals/ <p style="color: grey"> Python recipe 578658 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>). Revision 2. </p> <p>This based on another of my posted codes, titled "Spiral IFS Fractals".</p> Complex numbers dynamic allocation (C) 2013-05-15T08:54:39-07:00Emilianhttp://code.activestate.com/recipes/users/4186515/http://code.activestate.com/recipes/578519-complex-numbers-dynamic-allocation/ <p style="color: grey"> C recipe 578519 by <a href="/recipes/users/4186515/">Emilian</a> . </p> <p>Saregard</p> Retrieving product key with IronRuby (Ruby) 2012-11-03T18:22:01-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578320-retrieving-product-key-with-ironruby/ <p style="color: grey"> Ruby recipe 578320 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/ironruby/">ironruby</a>, <a href="/recipes/tags/productkey/">productkey</a>). </p> <p>If you like <a href="http://code.activestate.com/recipes/578317-product-key/?in=lang-text">IronPython script</a> for retrieving MS products' keys then you like IronRuby analog. Maybe...</p> Click counter for Windows (Python) 2012-06-26T18:08:25-07:00Krystian Rosińskihttp://code.activestate.com/recipes/users/4182314/http://code.activestate.com/recipes/578176-click-counter-for-windows/ <p style="color: grey"> Python recipe 578176 by <a href="/recipes/users/4182314/">Krystian Rosiński</a> (<a href="/recipes/tags/mouse/">mouse</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>Run script from cmd.</p> Split Up Text File by Line Count (Python) 2012-02-19T23:40:47-08:00Andrew Yurisichhttp://code.activestate.com/recipes/users/4180867/http://code.activestate.com/recipes/578045-split-up-text-file-by-line-count/ <p style="color: grey"> Python recipe 578045 by <a href="/recipes/users/4180867/">Andrew Yurisich</a> (<a href="/recipes/tags/split/">split</a>, <a href="/recipes/tags/text_files/">text_files</a>). Revision 5. </p> <p>Splits a large text file into smaller ones, based on line count. Original file is unmodified.</p> <p>Resulting text files are stored in the same directory as the original file.</p> <p>Useful for breaking up text based logs or blocks of email logins into smaller parts.</p> A metaclass that hides details of the attribute name when called. (Python) 2012-08-31T09:53:59-07:00Chaobin Tang (唐超斌)http://code.activestate.com/recipes/users/4174076/http://code.activestate.com/recipes/578249-a-metaclass-that-hides-details-of-the-attribute-na/ <p style="color: grey"> Python recipe 578249 by <a href="/recipes/users/4174076/">Chaobin Tang (唐超斌)</a> (<a href="/recipes/tags/metaclass/">metaclass</a>, <a href="/recipes/tags/python/">python</a>). Revision 2. </p> <p>In cases, where getting an attribute will expose to the client code the detail of the very attribute name, which could be changeable over time. This NamedAndCachedAttributeType is intended to hide this detail by mapping the real attribute name to another name that is maintained by the class itself. By doing so, the content provider(this class) and the client code(the caller) establish a deal that the changes of names are taken care of by the provider itself. Second, the value is set as a class variable once it is first retreived, as being cached.</p> Extremely Strong Password Generator (Python) 2012-06-19T13:25:03-07:00ajaymenon.khttp://code.activestate.com/recipes/users/4181225/http://code.activestate.com/recipes/578169-extremely-strong-password-generator/ <p style="color: grey"> Python recipe 578169 by <a href="/recipes/users/4181225/">ajaymenon.k</a> (<a href="/recipes/tags/password_generator/">password_generator</a>). Revision 6. </p> <p>I have written a generator that churns out really strong passwords. I have checked with a few password testers online which consistently rate the generated passwords with top marks.</p> A generic factory factory. (Python) 2012-06-11T23:31:11-07:00Eric Snowhttp://code.activestate.com/recipes/users/4177816/http://code.activestate.com/recipes/578165-a-generic-factory-factory/ <p style="color: grey"> Python recipe 578165 by <a href="/recipes/users/4177816/">Eric Snow</a> (<a href="/recipes/tags/factory/">factory</a>). </p> <p>Factories are useful for producing objects without having to store certain data on the objects' type. Instances of this factory class are factories that can produce </p> Easily Write Nested Loops (Python) 2012-02-18T01:34:55-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578046-easily-write-nested-loops/ <p style="color: grey"> Python recipe 578046 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/iteration/">iteration</a>, <a href="/recipes/tags/nested/">nested</a>). </p> <p>The "nest" generator function in this module is provided to make writing nested loops easier to accomplish. Instead of writing a for loop at each level, one may call "nest" with each sequence as an argument and receive items from the sequences correctly yielded back to the caller. A test is included at the bottom of this module to demonstrate how to use the code.</p> Auto Insert CSS Image Width/Height Macro: (JavaScript) 2011-11-16T15:23:03-08:00Skye Giordanohttp://code.activestate.com/recipes/users/4179718/http://code.activestate.com/recipes/577948-auto-insert-css-image-widthheight-macro/ <p style="color: grey"> JavaScript recipe 577948 by <a href="/recipes/users/4179718/">Skye Giordano</a> (<a href="/recipes/tags/css/">css</a>, <a href="/recipes/tags/height/">height</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/width/">width</a>). </p> <p>Based on the macro at <a href="http://community.activestate.com/forum/html-editing-img-tag-expansion-etc" rel="nofollow">http://community.activestate.com/forum/html-editing-img-tag-expansion-etc</a> I hacked together this alternate version that will auto insert the width: and height: of an image background in a CSS rule turning this:</p> <p>background: url(http://server.com/myImg.jpg) 0 0 no-repeat;</p> <p>...into this:</p> <p>background: url(http://server.com/myImg.jpg) 0 0 no-repeat; height: 252px; width: 200px;</p> Search sequences for sub-sequence (Python) 2011-08-19T05:17:00-07:00Steven D'Apranohttp://code.activestate.com/recipes/users/4172944/http://code.activestate.com/recipes/577850-search-sequences-for-sub-sequence/ <p style="color: grey"> Python recipe 577850 by <a href="/recipes/users/4172944/">Steven D'Aprano</a> (<a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/searching/">searching</a>, <a href="/recipes/tags/sequence/">sequence</a>, <a href="/recipes/tags/string/">string</a>, <a href="/recipes/tags/sublist/">sublist</a>, <a href="/recipes/tags/substring/">substring</a>). </p> <p>The list and tuple index() method and <code>in</code> operator test for element containment, unlike similar tests for strings, which checks for sub-strings:</p> <pre class="prettyprint"><code>&gt;&gt;&gt; "12" in "0123" True &gt;&gt;&gt; [1, 2] in [0, 1, 2, 3] False </code></pre> <p>These two functions, search and rsearch, act like str.find() except they operate on any arbitrary sequence such as lists:</p> <pre class="prettyprint"><code>&gt;&gt;&gt; search([1, "a", "b", 2, 3], ["b", 2]) 2 </code></pre> Combinations of a sequence without replacement using dynamic programming (Python) 2011-06-20T20:09:24-07:00Filippo Squillacehttp://code.activestate.com/recipes/users/4174931/http://code.activestate.com/recipes/577764-combinations-of-a-sequence-without-replacement-usi/ <p style="color: grey"> Python recipe 577764 by <a href="/recipes/users/4174931/">Filippo Squillace</a> . </p> <p>This recipe shows a way to solve the K-combinations problem without replacement with a sequence of items using the dynamic programming technique.</p> <p>If you want a divine but slower solution take into account a "divide et impera" paradigm like in this recipe: <a href="http://code.activestate.com/recipes/190465-generator-for-permutations-combinations-selections/" rel="nofollow">http://code.activestate.com/recipes/190465-generator-for-permutations-combinations-selections/</a></p> <p>This implementation could be improved overcoming some drawbacks. In particular, the inefficiency is due to the data structure used to store every set of combinations.</p> Python RGB and HSV Conversion (Python) 2009-10-01T06:33:56-07:00Michael Foglemanhttp://code.activestate.com/recipes/users/4171845/http://code.activestate.com/recipes/576919-python-rgb-and-hsv-conversion/ <p style="color: grey"> Python recipe 576919 by <a href="/recipes/users/4171845/">Michael Fogleman</a> (<a href="/recipes/tags/color/">color</a>, <a href="/recipes/tags/conversion/">conversion</a>, <a href="/recipes/tags/convert/">convert</a>, <a href="/recipes/tags/hsv/">hsv</a>, <a href="/recipes/tags/rgb/">rgb</a>). </p> <p>Python code to convert RGB to HSV and vice-versa.</p> Fern IFS Fractal (Python) 2010-03-21T16:00:51-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577134-fern-ifs-fractal/ <p style="color: grey"> Python recipe 577134 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>). </p> <p>Fern Fractal drawn using its Fractint IFS definition.</p> Julia fractals (Python) 2010-03-26T04:47:44-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577120-julia-fractals/ <p style="color: grey"> Python recipe 577120 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/random/">random</a>). Revision 2. </p> <p>It draws a randomly selected Julia fractal set each time.</p> Recursively querying for registry subkeys (Python) 2009-07-28T03:23:29-07:00Heinz Hermannhttp://code.activestate.com/recipes/users/4171265/http://code.activestate.com/recipes/576860-recursively-querying-for-registry-subkeys/ <p style="color: grey"> Python recipe 576860 by <a href="/recipes/users/4171265/">Heinz Hermann</a> (<a href="/recipes/tags/regdeletetree/">regdeletetree</a>, <a href="/recipes/tags/registry/">registry</a>, <a href="/recipes/tags/substitute/">substitute</a>, <a href="/recipes/tags/win32api/">win32api</a>). Revision 2. </p> <p>Because the Windows XP API does not support the RegDeleteTree function, the programmer has to query for subkeys of a registry key recursively, before he can delete it. This functions returns all subkeys of a registry key in deleteable order, which means the deepest subkey is the first in the list. </p> Parse a DIS PDU (Tcl) 2009-08-29T09:49:16-07:00Frank Bannonhttp://code.activestate.com/recipes/users/4167503/http://code.activestate.com/recipes/576892-parse-a-dis-pdu/ <p style="color: grey"> Tcl recipe 576892 by <a href="/recipes/users/4167503/">Frank Bannon</a> (<a href="/recipes/tags/dis/">dis</a>, <a href="/recipes/tags/pdu/">pdu</a>, <a href="/recipes/tags/udp/">udp</a>). </p> <p>Decodes Distributed Interactive Simulation (DIS) Protocol Data Units (PDUs) from UDP packets. Requires UDP package (<a href="http://tcludp.sourceforge.net%29" rel="nofollow">http://tcludp.sourceforge.net)</a></p> <p>Entity State (1), Fire (2), and Detonation (3) PDUs are decoded.</p>