Popular recipes tagged "meta:loc=147"http://code.activestate.com/recipes/tags/meta:loc=147/2011-03-18T14:39:59-07:00ActiveState Code RecipesSimple 1KHz Audio Function Generator Using Standard Python In Linux... (Python)
2011-03-01T19:37:16-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/577592-simple-1khz-audio-function-generator-using-standar/
<p style="color: grey">
Python
recipe 577592
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/function/">function</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/program/">program</a>, <a href="/recipes/tags/signal/">signal</a>, <a href="/recipes/tags/sound/">sound</a>, <a href="/recipes/tags/source/">source</a>).
</p>
<h5 id="simple-1khz-audio-function-generator-using-standard-python-in-linux-afgpy">Simple 1KHz Audio Function Generator Using Standard Python In Linux - afg.py</h5>
<p>This code is a stand alone program to generate a signal, at the earphone sockets, of 1KHz.
It is a basic audio signal generator and can be used as a starter test signal source for amateur electronics
enthusiasts testgear suite(s).</p>
<p>It needs /dev/audio to work; if you haven't got it then install oss-compat from your distro's repository.</p>
<p>Ensure the audio system is NOT in use for this to work.</p>
<p>Sine, Square, Triangle, Sawtooth+, Sawtooth-, Pulse+ and Pulse- signals are generated in 10 second bursts.
The waveforms generated are unfiltered and therefore not "pure", but hey, an audio function generator
signal source, for free, without external hardware, AND, using standard Python, what more do you want... :)
An oscilloscope will show the waveforms generated at the earphone socket.</p>
<p>Noise is not included but that is SO easy that I left it out FTTB.
(This will be a future upload. ;o)</p>
<p>All that is required to make this a piece of audio test equipment is a cable plugged into to the earphone
socket.</p>
<p>Assuming it is copied into the module(s) drawer just type:-</p>
<pre class="prettyprint"><code>>>> import afg[RETURN/ENTER]
</code></pre>
<p>And away you go...</p>
<p>This is Public Domain and you may do with it as you like.</p>
<p>Read the program for more information.
(There will be more to come in the future... :)</p>
Table indentation (Python)
2011-03-18T14:39:59-07:00Jonathan Blakeshttp://code.activestate.com/recipes/users/4177368/http://code.activestate.com/recipes/577615-table-indentation/
<p style="color: grey">
Python
recipe 577615
by <a href="/recipes/users/4177368/">Jonathan Blakes</a>
(<a href="/recipes/tags/text/">text</a>).
</p>
<p>A function for pretty-printing a table.</p>
Bit operation (C)
2011-02-27T05:21:35-08:00Shao-chuan Wanghttp://code.activestate.com/recipes/users/4168519/http://code.activestate.com/recipes/577589-bit-operation/
<p style="color: grey">
C
recipe 577589
by <a href="/recipes/users/4168519/">Shao-chuan Wang</a>
(<a href="/recipes/tags/bit/">bit</a>, <a href="/recipes/tags/operation/">operation</a>).
</p>
<p>A bit operation (could be very long).</p>
Named Tuples (Python)
2009-05-26T22:44:39-07:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/500261-named-tuples/
<p style="color: grey">
Python
recipe 500261
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/shortcuts/">shortcuts</a>).
Revision 15.
</p>
<p>Fast, lightweight attribute-style access to tuples.</p>
Component architecture through data descriptors and function decorators (Python)
2009-07-23T11:13:48-07:00Danny Ghttp://code.activestate.com/recipes/users/4164396/http://code.activestate.com/recipes/576852-component-architecture-through-data-descriptors-an/
<p style="color: grey">
Python
recipe 576852
by <a href="/recipes/users/4164396/">Danny G</a>
(<a href="/recipes/tags/abc/">abc</a>, <a href="/recipes/tags/abstract_base_class/">abstract_base_class</a>, <a href="/recipes/tags/component/">component</a>, <a href="/recipes/tags/interface/">interface</a>, <a href="/recipes/tags/plugin/">plugin</a>).
Revision 5.
</p>
<p>My desire was to design a class with defined attributes that when assigned on instances, would expand the instance's functionality. In other words if I create an instance of class A, then assign a 'component' attribute upon that instance, I should be able to call methods of the component object through the original instance. I believe this is somewhat similar to interfaces and abstract base classes (and I read up on both a bit), but I want to rely more on introspection of the object to see what it can do versus confining it to a set interface.</p>
Enhanced safe string formatting (Python)
2007-10-30T09:46:38-07:00Graham Horlerhttp://code.activestate.com/recipes/users/1704933/http://code.activestate.com/recipes/534139-enhanced-safe-string-formatting/
<p style="color: grey">
Python
recipe 534139
by <a href="/recipes/users/1704933/">Graham Horler</a>
(<a href="/recipes/tags/text/">text</a>).
Revision 6.
</p>
<p>Ever found "str" % (a,b) a bit limited?
Do you want to supply some arguments now, and fill the rest in later?
Or mix positional and named arguments, i.e. supply a tuple and a dict?
Do you want to put string templates in a configuration file to be read with ConfigParser?
I hope you like this recipe.</p>
simple crawler using twisted (Python)
2007-08-01T05:12:59-07:00Vaibhav Bhatiahttp://code.activestate.com/recipes/users/4007166/http://code.activestate.com/recipes/525493-simple-crawler-using-twisted/
<p style="color: grey">
Python
recipe 525493
by <a href="/recipes/users/4007166/">Vaibhav Bhatia</a>
(<a href="/recipes/tags/network/">network</a>).
</p>
<p>a simple recipe which can be used to download a webpage using twisted. Created this while going through the twisted documentation. supports the following :
- basic authentication
- check whether the page is updated
- progress bar</p>
Fixed keys mapping type (Python)
2007-01-12T00:29:57-08:00George Sakkishttp://code.activestate.com/recipes/users/2591466/http://code.activestate.com/recipes/499373-fixed-keys-mapping-type/
<p style="color: grey">
Python
recipe 499373
by <a href="/recipes/users/2591466/">George Sakkis</a>
(<a href="/recipes/tags/oop/">oop</a>).
Revision 3.
</p>
<p>A memory efficient implementation of a mapping type for mappings with fixed keys.</p>
big file sorting (Python)
2005-05-31T08:00:30-07:00Tomasz Bierutahttp://code.activestate.com/recipes/users/2467247/http://code.activestate.com/recipes/415581-big-file-sorting/
<p style="color: grey">
Python
recipe 415581
by <a href="/recipes/users/2467247/">Tomasz Bieruta</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>).
</p>
Using the Win32 IPHelper API (Python)
2005-03-23T12:13:33-08:00Zeb Bowdenhttp://code.activestate.com/recipes/users/2149829/http://code.activestate.com/recipes/392572-using-the-win32-iphelper-api/
<p style="color: grey">
Python
recipe 392572
by <a href="/recipes/users/2149829/">Zeb Bowden</a>
(<a href="/recipes/tags/network/">network</a>).
</p>
<p>This function will return a list of ports (TCP/UDP) that the current machine is listening on. It's basically a replacement for parsing netstat output but also serves as a good example for using the IP Helper API.</p>
Replace embedded Python code in a string with the results of executing that code (Python)
2001-03-09T05:30:56-08:00Joel Gouldhttp://code.activestate.com/recipes/users/98066/http://code.activestate.com/recipes/52217-replace-embedded-python-code-in-a-string-with-the-/
<p style="color: grey">
Python
recipe 52217
by <a href="/recipes/users/98066/">Joel Gould</a>
.
</p>
<p>This code was originally designed for dynamically creating HTML. It takes a template, which is a string that may included embedded Python code, and returns another string where any embedded Python is replaced with the results of executing that code.</p>