<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>tubes.motd.org</title>
	<atom:link href="http://tubes.motd.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://tubes.motd.org</link>
	<description>Messing around with tube radios</description>
	<lastBuildDate>Tue, 24 May 2011 21:03:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title></title>
		<link>http://tubes.motd.org/2011/05/121/</link>
		<comments>http://tubes.motd.org/2011/05/121/#comments</comments>
		<pubDate>Tue, 24 May 2011 18:01:37 +0000</pubDate>
		<dc:creator>mor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tubes.motd.org/?p=121</guid>
		<description><![CDATA[I love python. Here is a simple script to calculate parallel resistance (or series capacitance): #!/usr/bin/env python import sys divisor = 0 for component in sys.argv[1:]: divisor += 1 / float(component) print 1 / divisor Save this as something like parallel_resistance.py, then make it executable: $ chmod 755 parallel_resistance.py You can symlink to multiple easier [...]]]></description>
			<content:encoded><![CDATA[<p>I love python. Here is a simple script to calculate parallel resistance (or series capacitance):</p>
<p><strong>
<pre>#!/usr/bin/env python

import sys

divisor = 0

for component in sys.argv[1:]:
    divisor += 1 / float(component)

print 1 / divisor</pre>
<p></strong></p>
<p>Save this as something like parallel_resistance.py, then make it executable:</p>
<p><strong>
<pre>$ chmod 755 parallel_resistance.py</pre>
<p></strong></p>
<p>You can symlink to multiple easier to type (or easier to remember) program names like:</p>
<p><strong>
<pre>$ ln -s parallel_resistance.py par-res
$ ln -s parallel_resistance.py ser-cap</pre>
<p></strong></p>
<p>Then, run it with any number of like values of parallel resistance or series capacitance. Let&#8217;s say you have a 20pf and a couple of 30pf capacitors in series:</p>
<p><strong>
<pre>$ ./ser-cap 20 30 30
8.57142857143</pre>
<p></strong></p>
<p>This little script demonsrtates the ease with which you can step through any number of command line parameters using python&#8217;s list processing and &#8216;for&#8217; statement features. You need to convert the input to type float() or it will be assumed to be a string. Once the input is type float, math will always produce floating point results. If you had an integer you wanted to do floating point math on, you could also force it to float with something like: </p>
<p><strong>
<pre>divisor += 1.0 / integer_value</pre>
<p></strong></p>
<p>The &#8217;1.0&#8242; tells python you want a floating point result, not an integer. Cool. </p>
<p>Obviously if you wanted something more than ad hoc capability, you could check the input, generate error messages, add features with command line switches, etc.  But simple list processing of known command line values, and python&#8217;s default error handling is often more than adequate for tiny scripts like this&#8230; For example:</p>
<p><strong>
<pre>$ ./ser-cap 10 foo bar
Traceback (most recent call last):
  File "./ser-cap", line 8, in <module>
    divisor += 1 / float(component)
ValueError: invalid literal for float(): foo</pre>
<p></strong></p>
<p>Seems pretty easy to understand what went wrong.</p>
]]></content:encoded>
			<wfw:commentRss>http://tubes.motd.org/2011/05/121/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome to the Garage!</title>
		<link>http://tubes.motd.org/2011/05/welcome-to-the-garage/</link>
		<comments>http://tubes.motd.org/2011/05/welcome-to-the-garage/#comments</comments>
		<pubDate>Tue, 24 May 2011 16:31:29 +0000</pubDate>
		<dc:creator>mor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tubes.motd.org/?p=110</guid>
		<description><![CDATA[This is where it all happens. It&#8217;s my garage workbench, where I keep a number of handy dandy tools to help me restore the electronics in old radios. I like to use vintage test gear to work on vintage radios, so most of what you see there is also tube era technology, though I do [...]]]></description>
			<content:encoded><![CDATA[<p>This is where it all happens. It&#8217;s my garage workbench, where I keep a number of handy dandy tools to help me restore the electronics in old radios. I like to use vintage test gear to work on vintage radios, so most of what you see there is also tube era technology, though I do have a few cool transistorized devices visible.</p>
<ul>
<li><a href="http://tubes.motd.org/wp-content/uploads/2011/05/goto.png"><br />
<img class="alignright size-full wp-image-53" title="goto" src="http://tubes.motd.org/wp-content/uploads/2011/05/goto.png" alt="" width="632" height="511" /></a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tubes.motd.org/2011/05/welcome-to-the-garage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

