Popular recipes tagged "source"http://code.activestate.com/recipes/tags/source/2016-10-25T17:53:01-07:00ActiveState Code RecipesLines Of Code (LOC) (Python)
2016-10-25T17:53:01-07:00Jean Brouwershttp://code.activestate.com/recipes/users/2984142/http://code.activestate.com/recipes/580709-lines-of-code-loc/
<p style="color: grey">
Python
recipe 580709
by <a href="/recipes/users/2984142/">Jean Brouwers</a>
(<a href="/recipes/tags/count/">count</a>, <a href="/recipes/tags/lines/">lines</a>, <a href="/recipes/tags/python2/">python2</a>, <a href="/recipes/tags/python3/">python3</a>, <a href="/recipes/tags/source/">source</a>).
Revision 3.
</p>
<p>Count the number of lines (code, comment, blank) in one or several Python source files.</p>
Platform Independent White Noise Generator... (Python)
2012-11-25T10:10:45-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578350-platform-independent-white-noise-generator/
<p style="color: grey">
Python
recipe 578350
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/audio/">audio</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/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/noise/">noise</a>, <a href="/recipes/tags/program/">program</a>, <a href="/recipes/tags/pyaudio/">pyaudio</a>, <a href="/recipes/tags/signal/">signal</a>, <a href="/recipes/tags/sound/">sound</a>, <a href="/recipes/tags/source/">source</a>, <a href="/recipes/tags/windows/">windows</a>).
</p>
<p>This code is a derivative of the Pure Sinewave Generator and produces a continuous noise out of the speakers or headphone sockets.</p>
<p>It is for the hobbyist to be able to generate a pseudo-random noise signal for testing with.</p>
<p>It is issued as Public Domian and you may do with it as you please.</p>
<p>It is very easy to convert to Python 3.x.x but as OSX only has 2.7.x and lower ATM then these are what are used...</p>
<p>An installation of pyaudio IS needed for this to work; see the code for more information.</p>
<p>It is near platform independent but sadly the AMIGA is not included, but hey, I have already shown how generate sound for Classic AMIGAs.</p>
<p>Enjoy finding simple solutions to often very difficult problems...</p>
<p>Bazza, G0LCU...</p>
Platform Independent 1KHz Pure Audio Sinewave Generator... (Python)
2012-10-23T12:53:37-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578301-platform-independent-1khz-pure-audio-sinewave-gene/
<p style="color: grey">
Python
recipe 578301
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/audio/">audio</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/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/program/">program</a>, <a href="/recipes/tags/pyaudio/">pyaudio</a>, <a href="/recipes/tags/signal/">signal</a>, <a href="/recipes/tags/sinewave/">sinewave</a>, <a href="/recipes/tags/sound/">sound</a>, <a href="/recipes/tags/source/">source</a>, <a href="/recipes/tags/windows/">windows</a>).
Revision 2.
</p>
<p>IKHz_SW_OSX.py</p>
<p>A mono _pure_ sinewave generator using standard text mode Python 2.6.7 to at least 2.7.3.</p>
<p>This DEMO kids level 1KHz generator is mainly for a MacBook Pro, (13 inch in my case),
OSX 10.7.5 and above. See below...</p>
<p>It is another simple piece of testgear for the young amateur electronics enthusiast and
uses pyaudio fully installed for it to work.</p>
<p>PyAudio can be obtained from here:- <a href="http://people.csail.mit.edu/hubert/pyaudio/" rel="nofollow">http://people.csail.mit.edu/hubert/pyaudio/</a></p>
<p>This was primarily for a MacBook Pro, but works on at least 2 Linux flavours and Windows Vista 32 bit...</p>
<p>The sinewave generated is near excellent...</p>
<p>Enjoy finding simple solutions to often very difficult problems... Bazza, G0LCU...</p>
Find what class an attribute - ie, myObj.myAttr - comes from, and how it's defined (Python)
2012-10-26T12:59:47-07:00Paul Molodowitchhttp://code.activestate.com/recipes/users/4184064/http://code.activestate.com/recipes/578305-find-what-class-an-attribute-ie-myobjmyattr-comes-/
<p style="color: grey">
Python
recipe 578305
by <a href="/recipes/users/4184064/">Paul Molodowitch</a>
(<a href="/recipes/tags/attribute/">attribute</a>, <a href="/recipes/tags/attributes/">attributes</a>, <a href="/recipes/tags/class/">class</a>, <a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/inspection/">inspection</a>, <a href="/recipes/tags/source/">source</a>, <a href="/recipes/tags/__dict__/">__dict__</a>, <a href="/recipes/tags/__getattribute__/">__getattribute__</a>, <a href="/recipes/tags/__getattr__/">__getattr__</a>, <a href="/recipes/tags/__slots__/">__slots__</a>).
Revision 3.
</p>
<p>When inspecting new code (or when debugging), it can be handy to know exactly where a given attribute on an object or class comes from.</p>
<p>As a simple example, if you have a class MyClass, you might want to know where MyClass().myMethod is defined.</p>
<p>However, things can get tricky when things like __getattr__, __getattribute__, or even compiled objects come into play. That's where this function comes in. It returns what class a given attribute comes from, and what method was used to define it - ie, '__dict__' ('normal' definitions), '__slots__', '__getattr__', '__getattribute__', '(BUILTIN)'.</p>
<p>(Note - this function should't be relied on to be 100% accurate - rather, it's a best guess, for where to look to find it. It takes some pretty infrequent edge cases for it to be wrong, though...)</p>
Yet Another Python Generator... (Python)
2011-12-19T08:14:55-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/577990-yet-another-python-generator/
<p style="color: grey">
Python
recipe 577990
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/generator/">generator</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/signal/">signal</a>, <a href="/recipes/tags/sound/">sound</a>, <a href="/recipes/tags/source/">source</a>, <a href="/recipes/tags/sweep/">sweep</a>).
</p>
<p>Aha, but not what big guns were expecting...</p>
<p>LF Audio Sweep Generator.</p>
<p>Another kids level project to do for yourselves...</p>
<p>This is a Python DEMO to show the power of the sound card using Linux to
generate an Audio Sweep Signal from 4KHz down to 100Hz and back again.</p>
<p>Written in such a way that anyone can understand how it works...
This is for Linux and Python 2.x.x. Read the code for much more information, and......
A Python 3.x.x version is here:-</p>
<p><a href="http://www.linuxformat.com/forums/viewtopic.php?t=14411" rel="nofollow">http://www.linuxformat.com/forums/viewtopic.php?t=14411</a></p>
<p>Enjoy finding simple solutions to often VERY difficult problems...</p>
<p>Bazza, G0LCU...</p>
Simple White Noise Generator Using Standard Python In Linux. (Python)
2011-03-10T18:03:55-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/577604-simple-white-noise-generator-using-standard-python/
<p style="color: grey">
Python
recipe 577604
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/generator/">generator</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/noise/">noise</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>
<p>Simple White Noise Generator Using Standard Python In Linux - noise.py</p>
<p>This code is a stand alone program to generate a signal, at the earphone sockets, of white noise.</p>
<p>It needs /dev/dsp to work; if you haven't got it then install oss-compat from your distro's repository.
(NOTE:- /dev/audio could also be used but I decided to use /dev/dsp to show that this was within easy
reach of standard Python too.)</p>
<p>Ensure the audio system is NOT in use for this to work and all the levels are set up for your normal requirements.
In my case root level WAS NOT required but that does not mean that root level IS NOT required - so be aware.</p>
<p>All that is required to make this a piece of audio test equipment is a cable plugged into to the earphone
socket. The output level is fully controllable inside the code and the noise is generated in about 10 second
bursts</p>
<p>Assuming it is copied into the module(s) drawer just type:-</p>
<pre class="prettyprint"><code>>>> import noise[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>
<p>Enjoy finding simple solutions to often very difficult problems... ;o)</p>
<p>73...</p>
<p>Bazza, G0LCU...</p>
<p>Team AMIGA...</p>
Simple 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>
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>