Popular recipes by Chris Arndt http://code.activestate.com/recipes/users/1499228/2007-06-21T14:16:58-07:00ActiveState Code RecipesPlay sound files with pygame in a cross-platform manner (Python)
2007-06-21T14:16:58-07:00Chris Arndthttp://code.activestate.com/recipes/users/1499228/http://code.activestate.com/recipes/521884-play-sound-files-with-pygame-in-a-cross-platform-m/
<p style="color: grey">
Python
recipe 521884
by <a href="/recipes/users/1499228/">Chris Arndt</a>
(<a href="/recipes/tags/multimedia/">multimedia</a>, <a href="/recipes/tags/pygame/">pygame</a>, <a href="/recipes/tags/sound/">sound</a>, <a href="/recipes/tags/sysadmin/">sysadmin</a>).
Revision 4.
</p>
<p>This simple script shows how to play back a sound file using the mixer module from the pygame library. If you have pygame installed, this will work on all major platforms. The mixer module supports WAV and OGG files with many different sample rates, bits per sample and channels. The script will play back all supported files given on the command line sequentially.</p>
Get system/language/user dependent paths on windows (Python)
2006-02-05T11:54:03-08:00Chris Arndthttp://code.activestate.com/recipes/users/1499228/http://code.activestate.com/recipes/473846-get-systemlanguageuser-dependent-paths-on-windows/
<p style="color: grey">
Python
recipe 473846
by <a href="/recipes/users/1499228/">Chris Arndt</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
</p>
<p>This modules provides a few handy functions to retrieve the path names of some windows system directories from the registry [1] and the environment. These path names can be different depending on OS version, installation language, current user and personal setup. Because of this, they should not be included statically in your program.</p>
Easy to use object-oriented thread pool framework (Python)
2005-07-19T00:51:12-07:00Chris Arndthttp://code.activestate.com/recipes/users/1499228/http://code.activestate.com/recipes/435883-easy-to-use-object-oriented-thread-pool-framework/
<p style="color: grey">
Python
recipe 435883
by <a href="/recipes/users/1499228/">Chris Arndt</a>
(<a href="/recipes/tags/threads/">threads</a>).
Revision 3.
</p>
<p>A thread pool is a class that maintains a pool of worker threads to perform
time consuming operations in parallel. It assigns jobs to the threads
by putting them in a work request queue, where they are picked up by the
next available thread. This then performs the requested operation in the
background and puts the results in a another queue.</p>
<p>The thread pool class can then collect the results from all threads from
this queue as soon as they become available or after all threads have
finished their work. It's also possible, to define callbacks to handle
each result as it comes in.</p>
<p>Basic usage:</p>
<pre class="prettyprint"><code>>>> main = TreadPool(poolsize)
>>> requests = makeRequests(some_callable, list_of_args, callback)
>>> [main.putRequests(req) for req in requests]
>>> main.wait()
</code></pre>
<p>See the below for a longer, annotated usage example.</p>
Fill paragraph (Python)
2002-06-20T15:51:44-07:00Chris Arndthttp://code.activestate.com/recipes/users/1499228/http://code.activestate.com/recipes/134571-fill-paragraph/
<p style="color: grey">
Python
recipe 134571
by <a href="/recipes/users/1499228/">Chris Arndt</a>
(<a href="/recipes/tags/text/">text</a>).
</p>
<p>This Module contains a function that formats paragraphs of text to have a certain
linewidth, optionally stretching lines to that width by filling word gaps with
spaces. In other words, it does left-justified/word-wrapped and block formatted
paragraphs.</p>