Popular recipes tagged "generation"http://code.activestate.com/recipes/tags/generation/2012-07-10T19:52:17-07:00ActiveState Code RecipesFunny text generator (Python) 2011-12-25T11:14:39-08:00Pierre Quentelhttp://code.activestate.com/recipes/users/1552957/http://code.activestate.com/recipes/577988-funny-text-generator/ <p style="color: grey"> Python recipe 577988 by <a href="/recipes/users/1552957/">Pierre Quentel</a> (<a href="/recipes/tags/generation/">generation</a>, <a href="/recipes/tags/random/">random</a>, <a href="/recipes/tags/text/">text</a>). Revision 4. </p> <p>This class takes a text (preferably long enough) and generates another text that "looks like" the original. It won't mean anything, or just by chance ;-)</p> <p>For example, taking Hamlet, Act I, the program generates things like :</p> <p>Hamlet</p> <blockquote> <p>And vanish'd from our watch; <br /> His further. Fare third nights of the flushing immortal as it draw you into the flushing thy complete steel <br /> 'Tis sweet and each new-hatch'd: <br /> A country's father; <br /> To business and is prodigal thee! <br /> Have of crowing more the should I have heaven, <br /> Forward, therefore as ourself in the business it, Horatio <br /> To what is't that your watch, bid this here! </p> </blockquote> <p>Usage :</p> <pre class="prettyprint"><code>generator = TextGenerator(txt) result = generator.random_text(3000) </code></pre> Bash completed man and info pages generation (Python) 2011-08-24T03:14:13-07:00Josh Dhttp://code.activestate.com/recipes/users/4179060/http://code.activestate.com/recipes/577854-bash-completed-man-and-info-pages-generation/ <p style="color: grey"> Python recipe 577854 by <a href="/recipes/users/4179060/">Josh D</a> (<a href="/recipes/tags/a/">a</a>, <a href="/recipes/tags/all/">all</a>, <a href="/recipes/tags/and/">and</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/be/">be</a>, <a href="/recipes/tags/command/">command</a>, <a href="/recipes/tags/completed/">completed</a>, <a href="/recipes/tags/consume/">consume</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/first/">first</a>, <a href="/recipes/tags/generation/">generation</a>, <a href="/recipes/tags/get/">get</a>, <a href="/recipes/tags/in/">in</a>, <a href="/recipes/tags/info/">info</a>, <a href="/recipes/tags/line/">line</a>, <a href="/recipes/tags/man/">man</a>, <a href="/recipes/tags/modify/">modify</a>, <a href="/recipes/tags/must/">must</a>, <a href="/recipes/tags/only/">only</a>, <a href="/recipes/tags/pages/">pages</a>, <a href="/recipes/tags/possibilties/">possibilties</a>, <a href="/recipes/tags/possiblities/">possiblities</a>, <a href="/recipes/tags/py/">py</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/run/">run</a>, <a href="/recipes/tags/script/">script</a>, <a href="/recipes/tags/so/">so</a>, <a href="/recipes/tags/tab/">tab</a>, <a href="/recipes/tags/terminal/">terminal</a>, <a href="/recipes/tags/the/">the</a>, <a href="/recipes/tags/this/">this</a>, <a href="/recipes/tags/to/">to</a>). Revision 6. </p> <p>The script it self is very self explaining - the task is simple. *NIX only unless with cygwin perhaps?</p> <p>To start this open a terminal and strike the "Tab" key to get all possibilities (strike y, and strike the space key alot). Select all then Copy and save in "comms.txt" Modify the file so ONLY the possiblities consume a line; no prompts or extra newlines. (first line must be a command, the last line must be a command)</p> <p>Save the file ("~/Documents/bashing/comms.txt" is my path) then run this script in "~/Documents/bashing/".</p> <p>This generates two (2) files: "bash_help_man.sh", "bash_help_info.sh".</p> <p>Then it runs these files: "bash bash_help_man.sh", "bash bash_help_info.sh".</p> <p>This produces 2 files for every command (every line) in "comms.txt". All manpages are wrote in "mans/", all infopages are wrote in "infos/"</p> <p>There is now alot of files to read and organize; lets separate these by size. Directories are under1kb, under2kb, etc.</p> <p>Once complete do as you wish the files less than 128 kb; these files are COPIED into there new respective home, I repeat COPIED.</p> <p>The files 128 kb and higher ARE NOT copied to anywhere!</p> Some prime generation algorithms. (Python) 2010-08-06T11:20:34-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/577329-some-prime-generation-algorithms/ <p style="color: grey"> Python recipe 577329 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/generation/">generation</a>, <a href="/recipes/tags/is_prime/">is_prime</a>, <a href="/recipes/tags/prime/">prime</a>, <a href="/recipes/tags/primes/">primes</a>). Revision 4. </p> <p>Basic idea was to see the difference between different prime algorithms in time. Also they are not perfect the output shows that really higher numbers let grow the difference why I have separated this into functions to make it visible. I add this here because I have been missing this very often when I have been searching for algorithms.</p> <ul> <li>The 'is_prime' is a well known way of checkin for a number being prime or not.</li> <li>The sieve of Erastothenes is simply to strike out multiples of a given value; the primes will remain.</li> <li>the function 'profile' is a decorator for functions measuring the execution time</li> <li>Some information are in the comments of the code</li> </ul> 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> Generate a salt (PHP) 2012-07-10T19:52:17-07:00Xavier L.http://code.activestate.com/recipes/users/4171602/http://code.activestate.com/recipes/576894-generate-a-salt/ <p style="color: grey"> PHP recipe 576894 by <a href="/recipes/users/4171602/">Xavier L.</a> (<a href="/recipes/tags/crypt/">crypt</a>, <a href="/recipes/tags/generation/">generation</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/pass/">pass</a>, <a href="/recipes/tags/password/">password</a>, <a href="/recipes/tags/salt/">salt</a>, <a href="/recipes/tags/secure/">secure</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/string/">string</a>). Revision 6. </p> <p>This function will generate a salt for use with passwords ranging using characters in range a to z, A to Z, 0 to 9 and !@#$%&amp;<em>?. The characters are sorted in a random value and can appear more than one time in the string. This way, this function is more powerful than the *shuffle()</em> function. This means that the salt could also be longer than the character list.</p>