Most viewed recipes tagged "demo"http://code.activestate.com/recipes/tags/demo/views/2017-01-20T22:17:23-08:00ActiveState Code RecipesPosition The Cursor Almost Anywhere Inside Standard Text Mode Python Terminal. (Python)
2012-06-17T17:10:29-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578167-position-the-cursor-almost-anywhere-inside-standar/
<p style="color: grey">
Python
recipe 578167
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/amiga/">amiga</a>, <a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/cursor/">cursor</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/e_uae/">e_uae</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/locate/">locate</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/winuae/">winuae</a>).
</p>
<p>A DEMO showing the power of the ANSI (ASCII) _Esc_ codes in standard text mode Python.</p>
<p>ANSI _Esc_ codes here:- <a href="http://www.termsys.demon.co.uk/vtansi.htm" rel="nofollow">http://www.termsys.demon.co.uk/vtansi.htm</a></p>
<p>There are only three important things from the ANSI _Esc_ codes that are needed to obtain a neat finish to a program written in standard text mode Python:-</p>
<p>1) Clearing the screen. (Already done without the dedicated ANSI _Esc_ code!)</p>
<p>2) Colours and other character attributes. (Already done!)</p>
<p>3) A forced printing of a character or string from a given location inside the Terminal window.</p>
<p>To clear the screen does NOT require another dedicated ANSI _Esc_ code, (although it exists). This code uses the print("\r\n") method which works in all cases coupled with the one function supplied......</p>
<p>For The Classic AMIGA, E-UAE, WinUAE and Linux using Python(s) 1.4.0 to Python 3.2.2. Read the code for more information...</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>
Colo(u)rs Inside Text Mode Python... (Python)
2012-08-21T21:01:57-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578101-colours-inside-text-mode-python/
<p style="color: grey">
Python
recipe 578101
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/amiga/">amiga</a>, <a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/color/">color</a>, <a href="/recipes/tags/colour/">colour</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/display/">display</a>, <a href="/recipes/tags/e_uae/">e_uae</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/windows/">windows</a>, <a href="/recipes/tags/winuae/">winuae</a>).
Revision 2.
</p>
<p>A simple DEMO to show how to enhance Python inside a Terminal. This works on Classic AMIGAs, E-UAE,
Debian Linux 6.0.0, PCLinuxOS 2009, Windows XP and Vista and WinUAE, from Python 1.4.0 to 3.3A2.</p>
<p>Due to a complaint about my _fun_ upload recently I decided to post this so that the MANY can now
find out how to manipulate text inside a Python Terminal window so that it looks much better.</p>
<p>Read the code for more information...</p>
<p>Enjoy finding simple solutions to often very difficult problems...</p>
<p>Bazza...</p>
Banner (Python)
2011-01-11T05:16:12-08:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/577537-banner/
<p style="color: grey">
Python
recipe 577537
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/banner/">banner</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/formatting/">formatting</a>, <a href="/recipes/tags/printing/">printing</a>).
Revision 2.
</p>
<p>Easily customizable banner program.</p>
A DEMO to show how to write text into the Python terminal Title Bar... (Python)
2013-09-17T17:55:53-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578662-a-demo-to-show-how-to-write-text-into-the-python-t/
<p style="color: grey">
Python
recipe 578662
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/bar/">bar</a>, <a href="/recipes/tags/cygwin/">cygwin</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/title/">title</a>, <a href="/recipes/tags/title_bar/">title_bar</a>).
</p>
<p>This DEMO is show how to write some text of your choice into the Title Bar of the Python terminal window.</p>
<p>Firstly it imports "time" just for this demo so that a simple time delay can be generated.
Next the Python terminal window is written to for the 5 seconds of delay; see code.
And finally the Title Bar is restored to normal...</p>
<p>A snapshot image can be seen here:-</p>
<p><a href="http://wisecracker.host22.com/public/Title_Bar.jpg" rel="nofollow">http://wisecracker.host22.com/public/Title_Bar.jpg</a></p>
<p>Bazza...</p>
Record and Playbac using standard Python. (Python)
2011-02-25T19:33:59-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/577587-record-and-playbac-using-standard-python/
<p style="color: grey">
Python
recipe 577587
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/linux/">linux</a>, <a href="/recipes/tags/playback/">playback</a>, <a href="/recipes/tags/record/">record</a>, <a href="/recipes/tags/sound/">sound</a>).
</p>
<p>This very simple DEMO code records a few seconds of your voice from a microphone, (internal mic' on a laptop), and
replays your voice immedaiately after recording. It goes without saying that the RAW recording can be saved in
any extension of your choice and used as error reporting using the playback method.</p>
<p>There is the possibility of using it as a simple means of a single channel audio oscilloscope using the external
mic input and suitable Python GUI or with simple home built HW a seismometer recorder, plus other ideas.</p>
<p>Enjoy finding simple solutions to often very difficult problems...</p>
<p>Read the code for more information...</p>
<p>73...</p>
<p>Bazza, G0LCU...</p>
<p>Team AMIGA...</p>
SimpleTron3x.py "Game" To DEMO XY Drawing Using The Keyboard In Standard Text Mode Python. (Python)
2011-05-29T14:28:19-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/577728-simpletron3xpy-game-to-demo-xy-drawing-using-the-k/
<p style="color: grey">
Python
recipe 577728
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/anim/">anim</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/display/">display</a>, <a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/linux/">linux</a>).
</p>
<p>SimpleTron3x.py.</p>
<p>This code is a FUN program only to DEMO how to draw in a text mode Python shell.</p>
<p>There is an inkey() "function" extracted from a "class" recipe on this site.
See code for more information.</p>
<p>This was tested on PCLinuxOS 2009 with Python 3.0.x and Debian 6.0.0 with Python 3.1.x.</p>
<p>This ASSUMES an 80 x 24 Python shell window.</p>
<p>Issued as Public Domain, you may do as you like with this code.</p>
<p>Enjoy finding simple solutions to often very difficult problems.</p>
<p>Bazza...</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>
Simple LF Audio Oscilloscope Using Standard Python. (Python)
2011-04-07T17:17:57-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/577644-simple-lf-audio-oscilloscope-using-standard-python/
<p style="color: grey">
Python
recipe 577644
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/anim/">anim</a>, <a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/display/">display</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/oscilloscope/">oscilloscope</a>, <a href="/recipes/tags/scope/">scope</a>, <a href="/recipes/tags/sound/">sound</a>).
</p>
<p>AudioScope.py</p>
<p>I think this might be a first for both Python.</p>
<p>Initially uploaded to LXF, now also here under the MIT licence.</p>
<p>I am building a kids level seismometer and wanted to use standard Python inside Linux.</p>
<p>This DEMO code was my starter idea and looks as though using standard ASCII only might just work a real treat.</p>
<p>I've issued it to LXF under the MIT licence for future reasons.</p>
<p>It doesn't look much on screen except that the waveform(s) shown is/are a basic visual, electrical representation
of your voice. ;o)</p>
<p>It is possible to link the earphone socket on this notebook to the mic input and start the Audio Function
Generator, elsewhere in this site, in a separate Python terminal and see those waveforms inside the
AudioScope.py`s own Python terminal.</p>
<p>This grabs a 1 second 8KB burst, and then displays it onto the Python terminal. The timebase, amplitude, trigger,
single shot and others are not included but the main grab and display using /dev/dsp is shown. This can be made
platform independent by changing the /dev/dsp to something external like the Arduino Dev Board. This uses
STANDARD Python 2.5.x and later and tested on PCLinuxOS 2009 and Debian 6.0.0.</p>
<p>Enjoy finding simple solutions to often very difficult problems.</p>
<p>Bazza, G0LCU.</p>
Morse Code (Python)
2012-01-12T23:45:12-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578012-morse-code/
<p style="color: grey">
Python
recipe 578012
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/demonstration/">demonstration</a>, <a href="/recipes/tags/example/">example</a>, <a href="/recipes/tags/experiment/">experiment</a>, <a href="/recipes/tags/morse/">morse</a>, <a href="/recipes/tags/morse_code/">morse_code</a>, <a href="/recipes/tags/program/">program</a>, <a href="/recipes/tags/sound/">sound</a>).
Revision 3.
</p>
<p>After seeing another recipe recently that helps people with Morse Code, I was inspired to clean up the following code just a bit to make it worthy for the rest of the world. After being executed, it waits for lines of text to be entered, compiles each one in turn into timing codes, and plays them back with a simple execution</p>
Seven Bit Colored Analogue Bar Graph Generator DEMO... (Python)
2011-03-17T22:14:52-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/577612-seven-bit-colored-analogue-bar-graph-generator-dem/
<p style="color: grey">
Python
recipe 577612
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/analogue/">analogue</a>, <a href="/recipes/tags/anim/">anim</a>, <a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/bargraph/">bargraph</a>, <a href="/recipes/tags/color/">color</a>, <a href="/recipes/tags/colour/">colour</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/display/">display</a>, <a href="/recipes/tags/linux/">linux</a>).
Revision 3.
</p>
<p>..For STANDARD Python 2.6 and above...</p>
<p>This code will display a horizontal full colour analogue "VU" style meter. It displays green for normal, yellow
for warning and red for danger with a critical error beep near the end of full scale, at value 120+.</p>
<p>This version is for Python 2.6 and above and only for the Linux, (*nix?), platform.</p>
<p>It is an "at a glance" display that is in colour rather than having to read say a digitally generated number.</p>
<p>A Python 3.x version can be found here:-</p>
<p><a href="http://www.linuxformat.com/forums/viewtopic.php?t=13443" rel="nofollow">http://www.linuxformat.com/forums/viewtopic.php?t=13443</a></p>
<p>This has uses "for at a glance" voltmeters, ammeters, data-loggers, anemometers etc, etc...</p>
<p>Watch for wordwrapping etc...</p>
<p>NOTE:- This is Public Domain and you may do with it as you please.</p>
<p>73...</p>
<p>Bazza, G0LCU...</p>
<p>Team AMIGA...</p>
A Shell, Binary To Hexadecimal To Decimal Demo... (Bash)
2013-01-11T18:31:03-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578413-a-shell-binary-to-hexadecimal-to-decimal-demo/
<p style="color: grey">
Bash
recipe 578413
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/binary/">binary</a>, <a href="/recipes/tags/decimal/">decimal</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/hexadecimal/">hexadecimal</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/shell/">shell</a>, <a href="/recipes/tags/terminal/">terminal</a>).
</p>
<p>This little DEMO may be common knowledge to the big guns but not to amateurs like myself, so......</p>
<p>This is an Apple Macbbok Shell/Terminal DEMO shell script to show how to:-</p>
<p>1) Create a binary file...
2) Save it to your DEFAULT /directory/drwawer/folder/...
3) Display a hexadecimal dump of said binary file to prove that it is binary...
4) Select a single BYTE of that file and save it as an ASCII text decimal _number_, also to your DEFAULT /directory/drawer/folder/...
5) Read this ASCII text decimal number back in again...
6) Add this string representation to a number...
7) Stop...</p>
<p>It was intended purely for OSX 10.7.5 and above using the default terminal and shell...</p>
<p>It does work on many Linux flavours and shells/terminals also however.</p>
<p>Written so the anyone can understand what is going on.</p>
<p>The two files generated and saved in this DEMO to your DEFAULT /directory/drawer/folder/ are:-</p>
<p>BinaryString.dat
BinaryString.txt</p>
<p>This WILL lead to something very unusual in the not too distant future...</p>
<p>This is Public Domain and you may do with it as you wish...</p>
<p>Enjoy finding simple solutions to often very difficult problems...</p>
<p>Bazza, G0LCU...</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>
Metronome For Beginner Musicians... (Python)
2012-05-18T19:30:04-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578139-metronome-for-beginner-musicians/
<p style="color: grey">
Python
recipe 578139
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/linux/">linux</a>, <a href="/recipes/tags/metronome/">metronome</a>, <a href="/recipes/tags/music_accessory/">music_accessory</a>, <a href="/recipes/tags/sound/">sound</a>).
Revision 2.
</p>
<p>This DEMO code is a simple metronome for the Linux platform. It is for newcomers to playing musical instruments as a timing unit for practicing with.</p>
<p>It is issued as Public Domain and you may do with it as you please...</p>
<p>The device /dev/dsp IS required for this to work. If your machine lacks this then install oss-compat from you distro's repository.</p>
<p>It exploits a flaw in the default /dev/dsp device inside linux...</p>
<p>The part of the code the uses Ctrl-C to exit a loop has a flaw. This is not a bug. I will let the big guns explain what is happening if they want to in the comments section.</p>
<p>Enjoy finding simple solutions to often very difficult pronblems...</p>
<p>Bazza, G0LCU...</p>
A DEMO To Show How To Expand A Standard Python Terminal On The Fly... (Python)
2012-12-17T12:47:14-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578383-a-demo-to-show-how-to-expand-a-standard-python-ter/
<p style="color: grey">
Python
recipe 578383
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/campimeter/">campimeter</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/size/">size</a>, <a href="/recipes/tags/terminal/">terminal</a>, <a href="/recipes/tags/window/">window</a>).
</p>
<p>This code shows how to open up a default Terminal running Python to tha maximum allowed on the _desktop_. I decided on writing code to do a crude emulation of a Campimeter. Anyone who has worn spectacles for a long time has had this test done at the optician's. Originally written for a Macbook Pro, OSX 10.7.5 but also tested on Debian Linux 6.0.x. READ the code for more information!!! This code WILL alter the size of the Terminal window AND changes the colours too, although it is very easy to return back to the default state it is NOT included in the code... I EXPECT professionals to know how to doo that.</p>
<p>Before running Python inside the Terminal ensure the Terminal window is at the uppermost left hand corner of your desktop...</p>
<p>I needed the maximised Python Terminal for something else but this was the easiest way to demonstrate ho to do it through Python...</p>
<p>Written so that kids can understand what is going on...</p>
<p>Enjoy finding simple solutions to often very difficult problems... ;o)</p>
<p>Bazza, G0LCU...</p>
Design by contract on python vanilla (Python)
2013-11-05T20:50:30-08:00Alan Cristhian Ruizhttp://code.activestate.com/recipes/users/4186199/http://code.activestate.com/recipes/578767-design-by-contract-on-python-vanilla/
<p style="color: grey">
Python
recipe 578767
by <a href="/recipes/users/4186199/">Alan Cristhian Ruiz</a>
(<a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/design_pattern/">design_pattern</a>, <a href="/recipes/tags/productivity/">productivity</a>).
Revision 2.
</p>
<p>The code below is an example that shows that we can do design by contract in python without any non-standard module.</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>
A pseudo-echo, (or printf), function for any Python version. (Python)
2017-01-20T22:17:23-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/580750-a-pseudo-echo-or-printf-function-for-any-python-ve/
<p style="color: grey">
Python
recipe 580750
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/amiga/">amiga</a>, <a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/echo/">echo</a>, <a href="/recipes/tags/fs_uae/">fs_uae</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/printf/">printf</a>, <a href="/recipes/tags/unix/">unix</a>, <a href="/recipes/tags/windows/">windows</a>, <a href="/recipes/tags/winuae/">winuae</a>).
</p>
<p>A simple example of having a pseudo-echo using sys.stdout.write...</p>
<p>This gives exactly the same results from Python Versions, 1.4.0, 2.0.1, 2.5.6, 2.6.9, 3.4.3 and 3.5.2 on various platforms including the classic AMIGA A1200.</p>
<p>Enjoy finding simple solutions to often very difficult problems...</p>
<p>Bazza.</p>
Amplitude Modulation - Tremolo, Was:- An Audio/Sound Snippet For Linux... ;o) (Python)
2012-01-21T14:18:28-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578013-amplitude-modulation-tremolo-was-an-audiosound-sni/
<p style="color: grey">
Python
recipe 578013
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/amplitude/">amplitude</a>, <a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/mod/">mod</a>, <a href="/recipes/tags/modulation/">modulation</a>, <a href="/recipes/tags/sound/">sound</a>, <a href="/recipes/tags/tremolo/">tremolo</a>).
Revision 2.
</p>
<p>This IS for the big guns as well as the amatuer...</p>
<p>I am always being told that too many comments inside any code is bad and that professional coders are clever enough to work out what a program does without comments...</p>
<p>So here goes! This snippet of code hits /dev/dsp in Linux and has no comments as to what it does.
Make sure that /dev/dsp is available in your Linux install - if not then install oss.compat from your repository.</p>
<p>It needs Python 2.6 minimum, but may well work on a much earlier version</p>
<p>Don't run the code first but have a go at working out what it does and see if you are correct... ;o)</p>
<p>You can email me if you think you are/were correct:- <a href="http://wisecracker_at_tesco.net" rel="nofollow">wisecracker_at_tesco.net</a></p>
<p>Bear in mind I don't think this has ever been done before by hitting the /dev/dsp __directly__.</p>
<p>NOTE:- NO imports are required at all!!!</p>
<p>It runs for about 7 seconds before exiting...</p>
<p>Another BIG PLUS for Linux.</p>
<p>(I have a feeling poeple on here might like this, possibly even vote it up. ;)</p>
<p>Answer now at the bottom of this page...</p>
<p>Enjoy...</p>
<p>Bazza, G0LCU...</p>