Popular recipes tagged "code"http://code.activestate.com/recipes/tags/code/2014-07-22T16:23:39-07:00ActiveState Code RecipesSimple Cipher (Python)
2014-07-22T16:23:39-07:00Stephen Driffillhttp://code.activestate.com/recipes/users/4190452/http://code.activestate.com/recipes/578912-simple-cipher/
<p style="color: grey">
Python
recipe 578912
by <a href="/recipes/users/4190452/">Stephen Driffill</a>
(<a href="/recipes/tags/cipher/">cipher</a>, <a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/cryptography/">cryptography</a>).
</p>
<p>Takes a string and encodes it using a simple cipher.</p>
Python code clone detector (Don't Repeat Yourself) (Python)
2012-07-12T14:59:11-07:00frahttp://code.activestate.com/recipes/users/4182629/http://code.activestate.com/recipes/578206-python-code-clone-detector-dont-repeat-yourself/
<p style="color: grey">
Python
recipe 578206
by <a href="/recipes/users/4182629/">fra</a>
(<a href="/recipes/tags/analysis/">analysis</a>, <a href="/recipes/tags/clone/">clone</a>, <a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/dry/">dry</a>, <a href="/recipes/tags/duplication/">duplication</a>, <a href="/recipes/tags/parse/">parse</a>, <a href="/recipes/tags/similarity/">similarity</a>, <a href="/recipes/tags/static/">static</a>, <a href="/recipes/tags/syntax/">syntax</a>).
Revision 2.
</p>
<p>Find duplicate code in Python 2/3 source files. Write a nice report about it.</p>
<p>Works at the Abstract Syntax Tree level, which is a robust way to detect clones.
See this <a href="http://francois.boutines.free.fr/python-3.2-report.html">code duplicated in the Python 3.2 standard library</a>.</p>
<p><strong>Update</strong>: I cleaned the code a little bit, made it Python 2.7 compatible and faster.</p>
Samuel F. B. Morse's Code (Python)
2012-12-06T04:20:31-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578364-samuel-f-b-morses-code/
<p style="color: grey">
Python
recipe 578364
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/demonstration/">demonstration</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>).
</p>
<p>Many people have heard of Morse['s] Code, and it still is a helpful skill to have in certain context, as advanced as technology has become. The following recipe shows two sample ways that it can be implemented and shows some diversity in how problems can be solved in Python or many other languages for that matter.</p>
Simple Python Checker (Python)
2012-01-24T21:37:33-08:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578023-simple-python-checker/
<p style="color: grey">
Python
recipe 578023
by <a href="/recipes/users/4174477/">Thomas Lehmann</a>
(<a href="/recipes/tags/analyse/">analyse</a>, <a href="/recipes/tags/analyze/">analyze</a>, <a href="/recipes/tags/checker/">checker</a>, <a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/simple/">simple</a>).
Revision 2.
</p>
<p><strong>Why this recipe?</strong>:</p>
<ul>
<li>pylint is great but I does not support newer python versions.</li>
<li>I intended to write an own more simple parser recognizing that Python is doing the job for me and so I started to learn - a little - how to use AST.</li>
</ul>
<p><strong>In scope (for this recipe)</strong>:</p>
<ul>
<li>scanning a single python file displaying warnings and errors when breaking rules.</li>
<li>easy to maintain and easy extensible.</li>
<li>reporting messages in a way - when displayed in an editor - you can click on them to jump to the location for the relating message.</li>
<li>Lines of code means: without blanks (later: also without comments)</li>
</ul>
<p><strong>Out of scope (for this recipe)</strong>:</p>
<ul>
<li>For the recipe the folder/path support would break my limits. This include also the possible limits for this.</li>
<li>Checking for comments (SIngle line comments, block comments, checking for parameter documentation)</li>
</ul>
<p><strong>Future:</strong></p>
<ul>
<li>I'm thinking about putting this on a project base location (issue tracker, versioning, ...).</li>
<li>Of course same free license.</li>
<li>Providing a link here.</li>
<li>Checking for comments to handle further limits (LOC/COM, COM, checking for tags vs. parameters).</li>
<li>Allow to handle a path/folder with Python files (another statistic output)</li>
</ul>
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>
Simple Morse Code Generator And Tutor. (Python)
2012-01-09T22:51:12-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578009-simple-morse-code-generator-and-tutor/
<p style="color: grey">
Python
recipe 578009
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/generator/">generator</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/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 Generator and tutor that will generate the tones required for
the original standard letters A to Z and numbers 0 to 9. Puctuation is NOT included but
hey it is SOOOO simple to modify the code that I will let you, (the ones interested),
do that for yourselves... ;o)
Read the code for more informaton.</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>As it stands it _sends_ at around 8 WPM, (Words Per Minute).</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>
ActiveState recipe importer (Python)
2011-11-23T02:27:51-08:00nosklohttp://code.activestate.com/recipes/users/4166478/http://code.activestate.com/recipes/577958-activestate-recipe-importer/
<p style="color: grey">
Python
recipe 577958
by <a href="/recipes/users/4166478/">nosklo</a>
(<a href="/recipes/tags/activestate/">activestate</a>, <a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/import/">import</a>, <a href="/recipes/tags/library/">library</a>).
</p>
<p>Finally! This code allows you to import any activestate recipe right into your code!</p>
<p>Example:</p>
<pre class="prettyprint"><code>>>> from activestate.recipe194373 import mreplace
>>> print mreplace('ectave steta racipas rock!', ('a', 'e'), ('e', 'a'))
active state recipes rock!
</code></pre>
<p>Save this as <strong>activestate.py</strong></p>
linecount.py (Python)
2011-01-17T22:37:32-08:00Rémi Thebaulthttp://code.activestate.com/recipes/users/4176596/http://code.activestate.com/recipes/577546-linecountpy/
<p style="color: grey">
Python
recipe 577546
by <a href="/recipes/users/4176596/">Rémi Thebault</a>
(<a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/development/">development</a>, <a href="/recipes/tags/utility/">utility</a>).
Revision 2.
</p>
<p><strong>A code line counter</strong></p>
Recursive function to replace nested for loops (cartesian product) (Python)
2010-10-01T00:40:26-07:00Kieranhttp://code.activestate.com/recipes/users/4175132/http://code.activestate.com/recipes/577415-recursive-function-to-replace-nested-for-loops-car/
<p style="color: grey">
Python
recipe 577415
by <a href="/recipes/users/4175132/">Kieran</a>
(<a href="/recipes/tags/cartesian_product/">cartesian_product</a>, <a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/for_loop/">for_loop</a>, <a href="/recipes/tags/python/">python</a>).
Revision 3.
</p>
<p>Same functionality as the itertools product method (<a href="http://docs.python.org/library/itertools.html#itertools.product" rel="nofollow">http://docs.python.org/library/itertools.html#itertools.product</a>) with one major difference: generators are executed as the loop executes. An itertools product causes all the variables to be collected before the loop actually starts looping.</p>
Git Shell Script to enhance inline automation script... (Bash)
2010-11-01T00:43:03-07:00Patrick Riendeauhttp://code.activestate.com/recipes/users/4175653/http://code.activestate.com/recipes/577447-git-shell-script-to-enhance-inline-automation-scri/
<p style="color: grey">
Bash
recipe 577447
by <a href="/recipes/users/4175653/">Patrick Riendeau</a>
(<a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/concurrency/">concurrency</a>, <a href="/recipes/tags/git/">git</a>, <a href="/recipes/tags/oop/">oop</a>, <a href="/recipes/tags/oriented/">oriented</a>, <a href="/recipes/tags/programs/">programs</a>, <a href="/recipes/tags/property/">property</a>, <a href="/recipes/tags/property_creation/">property_creation</a>, <a href="/recipes/tags/repository/">repository</a>, <a href="/recipes/tags/shell/">shell</a>, <a href="/recipes/tags/shelve/">shelve</a>).
</p>
<p>This tiny effort, depend from Fnct.D ActiveState no.577446 Core, also available from github <a href="http://github.com/priendeau/Fnct.d" rel="nofollow">http://github.com/priendeau/Fnct.d</a>, can develop basic methodology of implementing oriented program within uses of function re-declaration with function-parser to create both property-function to discover uses of getter-function and setter-function</p>
Komodo JS Macro - show custom code completions (JavaScript)
2010-01-18T13:28:16-08:00Todd Whitemanhttp://code.activestate.com/recipes/users/2666241/http://code.activestate.com/recipes/577012-komodo-js-macro-show-custom-code-completions/
<p style="color: grey">
JavaScript
recipe 577012
by <a href="/recipes/users/2666241/">Todd Whiteman</a>
(<a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/codeintel/">codeintel</a>, <a href="/recipes/tags/completions/">completions</a>, <a href="/recipes/tags/javascript/">javascript</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/scintilla/">scintilla</a>, <a href="/recipes/tags/toddw/">toddw</a>).
</p>
<p>A <a href="http://www.activestate.com/komodo">Komodo</a> JavaScript macro that can be used to display a custom completion pop-up.</p>
<p><img src="http://community.activestate.com/files/images/custom_completions.png" alt="Completions image" /></p>
Scrambled word solving game (Python)
2009-12-03T19:48:56-08:00me mehttp://code.activestate.com/recipes/users/4172371/http://code.activestate.com/recipes/576963-scrambled-word-solving-game/
<p style="color: grey">
Python
recipe 576963
by <a href="/recipes/users/4172371/">me me</a>
(<a href="/recipes/tags/anagram/">anagram</a>, <a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/word/">word</a>).
Revision 4.
</p>
<p>Solve scrambled words. This game is made by a newbie to python so...</p>
Simple reverse converter of unicode code points string (Python)
2009-09-22T20:02:32-07:00Ryanhttp://code.activestate.com/recipes/users/4171767/http://code.activestate.com/recipes/576909-simple-reverse-converter-of-unicode-code-points-st/
<p style="color: grey">
Python
recipe 576909
by <a href="/recipes/users/4171767/">Ryan</a>
(<a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/points/">points</a>, <a href="/recipes/tags/prefix/">prefix</a>, <a href="/recipes/tags/reverse/">reverse</a>, <a href="/recipes/tags/str/">str</a>, <a href="/recipes/tags/string/">string</a>, <a href="/recipes/tags/u/">u</a>, <a href="/recipes/tags/unicode/">unicode</a>).
Revision 4.
</p>
<p>It's a simple recipe to convert a str type string with pure unicode code point (e.g string = <strong>"\u5982\u679c\u7231"</strong> ) to an unicode type string.
Actually, this method has the same effect with <strong>'u'</strong> prefix. But differently, it allows you to pass a variable of code points string as well as a constant one.</p>
Pastebin Upload (Python)
2013-05-26T10:54:25-07:00Joe Smithhttp://code.activestate.com/recipes/users/4168055/http://code.activestate.com/recipes/576805-pastebin-upload/
<p style="color: grey">
Python
recipe 576805
by <a href="/recipes/users/4168055/">Joe Smith</a>
(<a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/post/">post</a>, <a href="/recipes/tags/source/">source</a>, <a href="/recipes/tags/urllib2/">urllib2</a>).
Revision 2.
</p>
<p>A little script I made for some buddies and I. We are constantly collaborating on code. This scrips takes a source code file as it's parameter and uploads it to <a href="http://pastebin.com" rel="nofollow">pastebin.com</a> or any sub domain of pastebin.
I integrated it with the righ click window in windows. Without that integration the script wouldn't be as cool!
Hope others find it useful.</p>