<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>The Junction</title>
	
	<link>http://www.ethelred.org</link>
	<description />
	<lastBuildDate>Tue, 10 Nov 2009 17:13:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/ethelred" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>javascript in the shell</title>
		<link>http://www.ethelred.org/articles/2009/11/10/javascript-in-the-shell/</link>
		<comments>http://www.ethelred.org/articles/2009/11/10/javascript-in-the-shell/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 17:13:44 +0000</pubDate>
		<dc:creator>Edward</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.ethelred.org/?p=252</guid>
		<description><![CDATA[	Different languages are good for different things. But unix shell style trumps all. An example:

	bin/urlencode


#!/usr/bin/js
&#160;
function urlEncode&#40;str&#41;&#123;
    str=escape&#40;str&#41;;
    str=str.replace&#40;new RegExp&#40;'\\+','g'&#41;,'%2B'&#41;;
    return str.replace&#40;new RegExp&#40;'%20','g'&#41;,'+'&#41;;
&#125;
&#160;
&#160;
if&#40;arguments &#38;&#38; arguments.length &#62; 0&#41; &#123;
    for&#40;var i = 0; i &#60; arguments.length; i++&#41; &#123;
        [...]]]></description>
			<content:encoded><![CDATA[	<p>Different languages are good for different things. But unix shell style trumps all. An example:</p>

	<p><code>bin/urlencode</code></p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">#<span style="color: #339933;">!/</span>usr<span style="color: #339933;">/</span>bin<span style="color: #339933;">/</span>js
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> urlEncode<span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    str<span style="color: #339933;">=</span>escape<span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    str<span style="color: #339933;">=</span>str.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\\</span>+'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'g'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'%2B'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> str.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'%20'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'g'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'+'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>arguments <span style="color: #339933;">&amp;&amp;</span> arguments.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> arguments.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        r <span style="color: #339933;">=</span> urlEncode<span style="color: #009900;">&#40;</span>arguments<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">print</span><span style="color: #009900;">&#40;</span>r<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    importPackage<span style="color: #009900;">&#40;</span>java.<span style="color: #660066;">io</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    importPackage<span style="color: #009900;">&#40;</span>java.<span style="color: #660066;">lang</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    S <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> BufferedReader<span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">new</span> InputStreamReader<span style="color: #009900;">&#40;</span>System<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'in'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    s <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        s <span style="color: #339933;">=</span> S.<span style="color: #660066;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            r <span style="color: #339933;">=</span> urlEncode<span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066;">print</span><span style="color: #009900;">&#40;</span>r<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


	<p>Notes:
	<ul>
		<li>This works because <code>/usr/bin/js</code> on my system runs <a href="https://developer.mozilla.org/en/Rhino_Shell">Rhino</a></li>
	</ul>
	<ul>
		<li>function stolen from <a href="http://ostermiller.org/calc/encode.html">steveo</a></li>
	</ul></p><img src="http://feeds.feedburner.com/~r/ethelred/~4/eibya_1u02k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ethelred.org/articles/2009/11/10/javascript-in-the-shell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Health Care Debate part 1</title>
		<link>http://www.ethelred.org/articles/2009/08/13/health-care-debate-part-1/</link>
		<comments>http://www.ethelred.org/articles/2009/08/13/health-care-debate-part-1/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 13:20:14 +0000</pubDate>
		<dc:creator>Edward</dc:creator>
				<category><![CDATA[discussion]]></category>
		<category><![CDATA[immigrant]]></category>
		<category><![CDATA[politics]]></category>

		<guid isPermaLink="false">http://www.ethelred.org/articles/2009/08/13/health-care-debate-part-1/</guid>
		<description><![CDATA[	I&#8217;ve been meaning to write comparing British and US health care for a while, but it&#8217;s not a very easy topic to get around. However it is the main subject in the news these days so it&#8217;s about time I weigh in.

	The most emotive piece I&#8217;ve heard on the radio this week was from one [...]]]></description>
			<content:encoded><![CDATA[	<p>I&#8217;ve been meaning to write comparing British and US health care for a while, but it&#8217;s not a very easy topic to get around. However it is the main subject in the news these days so it&#8217;s about time I weigh in.</p>

	<p>The most emotive piece I&#8217;ve heard on the radio this week was from one of many &#8216;town hall&#8217; meetings (I forget which). A sobbing woman says, &#8220;The president is trying to make us like Russia. I don&#8217;t want America to be Socialist!&#8221;</p>

	<p>Of course, being me, this leaves me thinking, &#8220;but why?&#8221;. The speaker obviously thinks &#8216;Socialist&#8217; is a &#8216;bad word&#8217; &#8211; I don&#8217;t. (I&#8217;ll leave aside the debate over whether Russia is really socialist any more). Since the quote doesn&#8217;t give any more reasoning, I&#8217;m left to wonder what this woman is actually opposed to &#8211; she clearly feels strongly about it.</p>

	<p>Unfortunately, to me, the opposite of socialism seems to be selfishness. Selfishness in health care seems to lead to a situation where you are fine while you remain healthy but if you are unlucky enough to get sick you&#8217;d better hope you can afford it. A lot of illness isn&#8217;t selfish, by the way &#8211; the flu is happy to spread fairly to all people, given the chance.</p>

	<p>In practice paying for US health care is somewhere along the selfish/social scale. As companies or organisations buy group insurance plans, they form small pockets of socialness. The only reason insurance works is because it spreads the cost across a group of people, with the assumption that not everyone will suffer illness. So people who pay insurance premiums and are healthy, are necessarily subsidising the health care of people in the same group who are less healthy. That sounds like socialism to me.</p>

	<p>Of course, the American argument is that people have freedom of choice about what insurance they buy, or don&#8217;t buy<sup class="footnote"><a href="#fn11962857964afa1213eb2f4">1</a></sup>, and that the current debate is about the government taking away that freedom. I need to think more about that, so maybe more later.</p>

	<p id="fn11962857964afa1213eb2f4" class="footnote"><sup>1</sup> I live in Massachusetts, and it is mandatory for people here to have some kind of health insurance.</p><img src="http://feeds.feedburner.com/~r/ethelred/~4/ADOXL_fOrWA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ethelred.org/articles/2009/08/13/health-care-debate-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>basement music player part 1</title>
		<link>http://www.ethelred.org/articles/2009/07/06/basement-music-player-part-1/</link>
		<comments>http://www.ethelred.org/articles/2009/07/06/basement-music-player-part-1/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 18:34:22 +0000</pubDate>
		<dc:creator>Edward</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.ethelred.org/articles/2009/07/06/basement-music-player-part-1/</guid>
		<description><![CDATA[	Having got the old computer hooked up to the network I proceeded to work on its setup. My main intention for it is to play music from the network drive, while I&#8217;m down in the basement working on my other hobbies.

	I upgraded it with the latest Debian, since that is about the only Linux distribution [...]]]></description>
			<content:encoded><![CDATA[	<p>Having <a href="http://www.ethelred.org/articles/2009/07/06/recycling/">got the old computer hooked up to the network</a> I proceeded to work on its setup. My main intention for it is to play music from the network drive, while I&#8217;m down in the basement working on my other hobbies.</p>

	<p>I upgraded it with the latest Debian, since that is about the only Linux distribution with a supported PowerPC version now (the computer is an iMac G3). Since I am used to Ubuntu, Debian is pretty similar.</p>

	<p>Next I wanted to cut down the number of steps I had to take to get the machine on and playing music. I created a new user called &#8216;music&#8217;, and set up <span class="caps">GDM</span> (using the &#8216;Login Window&#8217; preferences entry) so that it automatically logs in as that user (after 20 seconds, so I can still log in as a normal user if necessary). </p>

	<p>Then I set up the user so that Rhythmbox starts automatically when they log in &#8211; since I&#8217;m using <span class="caps">LXDE</span>, this meant finding <code>rhythmbox.desktop</code> and copying it under <code>~/.config/autostart/</code></p>

	<p>So now I can press the power button, and (after a while) the music user will be logged in with Rhythmbox on screen. I still have to go and click on the network music server icon before it loads up songs though, so that will be the next thing to fix. Having searched around, I think I&#8217;m going to have to learn to write a Rhythmbox plugin to make that work how I want&#8230;</p><img src="http://feeds.feedburner.com/~r/ethelred/~4/vqnE4VTTziw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ethelred.org/articles/2009/07/06/basement-music-player-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>recycling</title>
		<link>http://www.ethelred.org/articles/2009/07/06/recycling/</link>
		<comments>http://www.ethelred.org/articles/2009/07/06/recycling/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 13:14:50 +0000</pubDate>
		<dc:creator>Edward</dc:creator>
				<category><![CDATA[hardware]]></category>
		<category><![CDATA[network]]></category>

		<guid isPermaLink="false">http://www.ethelred.org/articles/2009/07/06/recycling/</guid>
		<description><![CDATA[	A while back, I put our old computer elizabeth on a shelf in the basement. Frustratingly, it was fairly close to our cable modem, which is connected to the home network, but there is only a single cable run up to the router which is on the first (ground) floor, and which is where it [...]]]></description>
			<content:encoded><![CDATA[	<p>A while back, I put our old computer <a href="http://www.ethelred.org/computers">elizabeth</a> on a shelf in the basement. Frustratingly, it was fairly close to our cable modem, which is connected to the home network, but there is only a single cable run up to the router which is on the first (ground) floor, and which is where it would really need to connect to, and I didn&#8217;t fancy drilling more holes in the walls and floor. But I remembered having read at some point that 10/100 ethernet only uses two of the pairs of wires in a cable, and cat 5 or 6 cable has four pairs in it. So I did some more research on the web which suggested that <a href="http://www.derose.net/steve/guides/wiring/#pinouts">with the correct connectors, you could run two connections through a single cable</a> </p>

	<p>Since I was being cheap, I built my own connectors. I broke up a junk 10Mb router to take the sockets out of it, and cut up some spare patch cables to get short lengths with a plug on one end. By referring to <a href="http://www.dragon-it.co.uk/files/cat5_colour_codes.htm">this colour code diagram</a> I wired up my connectors so I would have a &#8216;straight through&#8217; path on the orange and green pairs, and a diverted path which connected the &#8216;external&#8217; orange and green pairs to the brown and blue pairs in the single cable. With an hour or so of (bad) soldering I put my connectors together &#8211; and then the moment of truth &#8211; I reconnected the modem and router ends of the cable, and connected in the computer in the basement, and it all worked! </p><img src="http://feeds.feedburner.com/~r/ethelred/~4/723YLUKUk8w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ethelred.org/articles/2009/07/06/recycling/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Comcast are scum</title>
		<link>http://www.ethelred.org/articles/2009/06/25/comcast-are-scum/</link>
		<comments>http://www.ethelred.org/articles/2009/06/25/comcast-are-scum/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 13:12:08 +0000</pubDate>
		<dc:creator>Edward</dc:creator>
				<category><![CDATA[frustration]]></category>
		<category><![CDATA[hardware]]></category>

		<guid isPermaLink="false">http://www.ethelred.org/articles/2009/06/25/comcast-are-scum/</guid>
		<description><![CDATA[	The &#8216;Digital Television Switchover&#8217; took place here a couple of weeks ago. Not long after, we received this letter from Comcast[PDF 900kB]. While I suspect it doesn&#8217;t say anything that is actively illegal, I do think it could be highly misleading and is taking advantage of less well informed people1.

	
Q: How do I get my [...]]]></description>
			<content:encoded><![CDATA[	<p>The &#8216;Digital Television Switchover&#8217; took place here a couple of weeks ago. Not long after, we received <a href='http://www.ethelred.org/wp-content/uploads/2009/06/comcast_dtv_letter.pdf' title='Comcast DTV letter'>this letter from Comcast</a><sup>[<span class="caps">PDF</span> 900kB]</sup>. While I suspect it doesn&#8217;t say anything that is actively illegal, I do think it could be highly misleading and is taking advantage of less well informed people<sup class="footnote"><a href="#fn2146651614afa121412632">1</a></sup>.</p>

	<p><blockquote><em><br />
<strong>Q: How do I get my signal back?</strong><br />
A: There are several options, but the easy answer is to call Comcast.<br />
</em></blockquote><br />
How do you quantify &#8216;easy&#8217;? Comcast&#8217;s offer probably is &#8216;easy&#8217; in the sense that once you request their service, they&#8217;ll send an installer over to set everything up for you. Of course <span class="caps">RCN</span>, Verizon, DirecTV, Dish Network or others would do the same thing, so it pays to shop around, if that&#8217;s what you want. They&#8217;ll all need to you stay at home to wait for the installer, then add some extra boxes to the outside of your house, drill holes and run cable around.</p>

	<p>Assuming you have a TV antenna in place, I think it&#8217;s quite easy to buy a digital converter box, connect the antenna to it, and connect it to the TV.</p>

	<p><blockquote><em><br />
<strong>Q: How do I get <span class="caps">FREE</span> Basic Cable?</strong><br />
A: It&#8217;s easy&#8230; sign up for Internet and/or phone (each starting at just $24.95/mo.)<br />
</em></blockquote><br />
So this is that special kind of &#8216;free&#8217; where actually you have to pay for something. Whichever deal you choose you&#8217;re out a minimum of $10 every month to Comcast, and reading the small print you may also have to pay for equipment, installation, taxes and other fees. Don&#8217;t forget, it&#8217;s only &#8216;free&#8217; for the first year. Do you expect to watch TV for longer than a year?</p>

	<p>Compare this to a digital converter box. You can <a href="http://dtv.gov/">request a converter box coupon</a> which gives you $40 off the price. The boxes are selling for around $40 &#8211; $60, so your maximum outlay will be about $20 (plus sales tax), with no ongoing cost. If you were previously watching broadcast TV, you can use the same antenna. </p>

	<p><strong>Should you take up Comcast&#8217;s offer?</strong><br />
I don&#8217;t intend to. I don&#8217;t think it gains you anything other than another monthly bill. If you just want to get broadcast TV back, a converter box is a cheaper option. If you really want cable, look around at all the possibilities.</p>

	<p id="fn2146651614afa121412632" class="footnote"><sup>1</sup> Though my impression of US culture is that there is more of an expectation for people to inform themselves to avoid being taken advantage of.</p><img src="http://feeds.feedburner.com/~r/ethelred/~4/ZzxZGsW7zgU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ethelred.org/articles/2009/06/25/comcast-are-scum/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>dns323 podcast and torrent downloader</title>
		<link>http://www.ethelred.org/articles/2009/06/19/dns323-podcast-and-torrent-downloader/</link>
		<comments>http://www.ethelred.org/articles/2009/06/19/dns323-podcast-and-torrent-downloader/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 10:39:59 +0000</pubDate>
		<dc:creator>Edward</dc:creator>
				<category><![CDATA[network]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.ethelred.org/articles/2009/06/19/dns323-podcast-and-torrent-downloader/</guid>
		<description><![CDATA[	I&#8217;ve expanded on my previous podcast downloader program so that it gets torrents as well. I was running Automatic but it seemed silly to have two programs doing more or less the same thing.

	I also didn&#8217;t like the configuration of Automatic, which has a global set of regexps it applies to all feeds to decide [...]]]></description>
			<content:encoded><![CDATA[	<p>I&#8217;ve expanded on my <a href="http://www.ethelred.org/articles/2009/03/09/dns323-podcast-downloader/">previous podcast downloader</a> program so that it gets torrents as well. I was running <a href="http://forum.dsmg600.info/viewtopic.php?pid=15546">Automatic</a> but it seemed silly to have two programs doing more or less the same thing.</p>

	<p>I also didn&#8217;t like the configuration of Automatic, which has a global set of regexps it applies to all feeds to decide whether to download an item. My program has separate regexps for each feed<sup class="footnote"><a href="#fn17652672094afa121430a8f">1</a></sup> which I think is a bit easier to deal with. In order to make the config file easy to parse, it is actually another Ruby file, which is read with <code>instance_eval</code>. By having methods defined as <code>feed</code> and <code>matches</code> the config file can just use those and look relatively sane:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">feed <span style="color:#996600;">'http://some.feed.url/blah.rss'</span>
matches <span style="color:#996600;">'title.to.match.*<span style="color:#000099;">\d</span>+'</span></pre></div></div>


	<p>(Some people would call this a <span class="caps">DSL</span>, but I think that&#8217;s stretching a point)</p>

	<p>To make the torrents get into Transmission, the torrent downloader we&#8217;re using, I just call the <code>transmission-remote</code> command. Sometimes it&#8217;s easier to use what works.</p>

	<p>So here&#8217;s the full program (see <a href="http://www.ethelred.org/articles/2009/03/09/dns323-podcast-downloader/">my previous post</a> for how to set things up on the DNS-323):</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/ffp/bin/env ruby</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'open-uri'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rss'</span>
&nbsp;
CONFFILE=<span style="color:#996600;">'/ffp/etc/mypodder2.conf'</span>
PODCASTDIR=<span style="color:#996600;">'/mnt/HD_a2/podcasts'</span>
TORRENTDIR=<span style="color:#996600;">'/mnt/HD_a2/torrents'</span>
TORRENT_UPLOAD=<span style="color:#996600;">'/ffp/bin/transmission-remote &quot;127.0.0.1:9091&quot; -a &quot;%s&quot;'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> ConfigParser
	<span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>feeds<span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#0066ff; font-weight:bold;">@feeds</span> = feeds
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">def</span> parse<span style="color:#006600; font-weight:bold;">&#40;</span>file<span style="color:#006600; font-weight:bold;">&#41;</span>
		instance_eval<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">read</span><span style="color:#006600; font-weight:bold;">&#40;</span>file<span style="color:#006600; font-weight:bold;">&#41;</span>, file<span style="color:#006600; font-weight:bold;">&#41;</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">def</span> feed<span style="color:#006600; font-weight:bold;">&#40;</span>url<span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#0066ff; font-weight:bold;">@current</span> = Feed.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>url<span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#0066ff; font-weight:bold;">@feeds</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#0066ff; font-weight:bold;">@current</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">def</span> matches<span style="color:#006600; font-weight:bold;">&#40;</span>pattern<span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#0066ff; font-weight:bold;">@current</span>.<span style="color:#9900CC;">add_pattern</span><span style="color:#006600; font-weight:bold;">&#40;</span>pattern<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@current</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">alias</span> <span style="color:#ff3333; font-weight:bold;">:or</span> <span style="color:#ff3333; font-weight:bold;">:matches</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Feed
	<span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>url<span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#0066ff; font-weight:bold;">@url</span> = url
		<span style="color:#0066ff; font-weight:bold;">@patterns</span> = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">def</span> uri
		<span style="color:#0066ff; font-weight:bold;">@url</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">def</span> add_pattern<span style="color:#006600; font-weight:bold;">&#40;</span>pattern<span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#9966CC; font-weight:bold;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>pattern <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> pattern.<span style="color:#9900CC;">length</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>
			<span style="color:#0066ff; font-weight:bold;">@patterns</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#CC00FF; font-weight:bold;">Regexp</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>pattern, <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#9966CC; font-weight:bold;">end</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">def</span> allow?<span style="color:#006600; font-weight:bold;">&#40;</span>item<span style="color:#006600; font-weight:bold;">&#41;</span>
		icompare = item.<span style="color:#9900CC;">title</span>
		<span style="color:#0066ff; font-weight:bold;">@patterns</span>.<span style="color:#9900CC;">empty</span>? <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#0066ff; font-weight:bold;">@patterns</span>.<span style="color:#9900CC;">find</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>p<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#CC0066; font-weight:bold;">p</span> =~ icompare<span style="color:#006600; font-weight:bold;">&#125;</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Main
	<span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>options = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#0066ff; font-weight:bold;">@options</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>:config <span style="color:#006600; font-weight:bold;">=&gt;</span> CONFFILE, <span style="color:#ff3333; font-weight:bold;">:verbose</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">merge</span><span style="color:#006600; font-weight:bold;">&#40;</span>options<span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#0066ff; font-weight:bold;">@feeds</span> = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
		read_config
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">def</span> read_config
		ConfigParser.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>@feeds<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span>@options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:config</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">def</span> vprintln<span style="color:#006600; font-weight:bold;">&#40;</span>sometext<span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#9966CC; font-weight:bold;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>@options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:verbose</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
			<span style="color:#CC0066; font-weight:bold;">puts</span> sometext
		<span style="color:#9966CC; font-weight:bold;">end</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">def</span> torrent?<span style="color:#006600; font-weight:bold;">&#40;</span>item<span style="color:#006600; font-weight:bold;">&#41;</span>
		item.<span style="color:#9900CC;">enclosure</span>.<span style="color:#9900CC;">type</span> =~ <span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#006600; font-weight:bold;">*</span>torrent<span style="color:#006600; font-weight:bold;">/</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">def</span> run<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#0066ff; font-weight:bold;">@feeds</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>feed<span style="color:#006600; font-weight:bold;">|</span>
    vprintln <span style="color:#996600;">&quot;checking feed #{feed.uri}&quot;</span>
    rss_content = <span style="color:#996600;">&quot;&quot;</span>
    <span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>feed.<span style="color:#9900CC;">uri</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span>
        rss_content = f.<span style="color:#9900CC;">read</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    rss = <span style="color:#6666ff; font-weight:bold;">RSS::Parser</span>.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span>rss_content, <span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
    rss.<span style="color:#9900CC;">items</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>item<span style="color:#006600; font-weight:bold;">|</span>
        vprintln <span style="color:#996600;">&quot; + checking item #{item.title}&quot;</span>
        <span style="color:#9966CC; font-weight:bold;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>item.<span style="color:#9900CC;">enclosure</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> feed.<span style="color:#9900CC;">allow</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>item<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
            iurl = item.<span style="color:#9900CC;">enclosure</span>.<span style="color:#9900CC;">url</span>
            vprintln <span style="color:#996600;">&quot; + + allowed item #{iurl}&quot;</span>
            ctitle = rss.<span style="color:#9900CC;">channel</span>.<span style="color:#9900CC;">title</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>\W<span style="color:#006600; font-weight:bold;">/</span>, <span style="color:#996600;">'_'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
		base = PODCASTDIR
		base = TORRENTDIR <span style="color:#9966CC; font-weight:bold;">if</span> torrent?<span style="color:#006600; font-weight:bold;">&#40;</span>item<span style="color:#006600; font-weight:bold;">&#41;</span>
            <span style="color:#CC0066; font-weight:bold;">system</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;mkdir -p #{File.join(base, ctitle)}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
            <span style="color:#CC0066; font-weight:bold;">system</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;chmod a+rw #{File.join(base, ctitle)}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
            ifile = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>base, ctitle, <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">basename</span><span style="color:#006600; font-weight:bold;">&#40;</span>iurl<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
            <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exists</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>ifile<span style="color:#006600; font-weight:bold;">&#41;</span>
            	<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;About to download #{iurl} as #{ifile}&quot;</span>
            	<span style="color:#CC0066; font-weight:bold;">system</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;wget -O #{ifile} #{iurl}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
		<span style="color:#9966CC; font-weight:bold;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>torrent?<span style="color:#006600; font-weight:bold;">&#40;</span>item<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exists</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>ifile<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
			<span style="color:#CC0066; font-weight:bold;">system</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">sprintf</span><span style="color:#006600; font-weight:bold;">&#40;</span>TORRENT_UPLOAD, ifile<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
		<span style="color:#9966CC; font-weight:bold;">end</span>
            <span style="color:#9966CC; font-weight:bold;">else</span>
            	vprintln <span style="color:#996600;">&quot; + + file exists&quot;</span>
            <span style="color:#9966CC; font-weight:bold;">end</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>                                
<span style="color:#9966CC; font-weight:bold;">end</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0000FF; font-weight:bold;">__FILE__</span> == $<span style="color:#006666;">0</span>
	<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'optparse'</span>
&nbsp;
	options = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
	opts = OptionParser.<span style="color:#9900CC;">new</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>op<span style="color:#006600; font-weight:bold;">|</span>
		op.<span style="color:#9900CC;">on</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;-f CONFIG&quot;</span>, <span style="color:#996600;">&quot;--config CONFIG&quot;</span>, <span style="color:#996600;">&quot;Specify config file (default #{CONFFILE})&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span>
		      options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:config</span><span style="color:#006600; font-weight:bold;">&#93;</span> = f
	        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
		op.<span style="color:#9900CC;">on</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;-v&quot;</span>, <span style="color:#996600;">&quot;--verbose&quot;</span>, <span style="color:#996600;">&quot;Output messages&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
		      options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:verbose</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
	        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	        <span style="color:#008000; font-style:italic;"># No argument, shows at tail.  This will print an options summary.</span>
	        op.<span style="color:#9900CC;">on_tail</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;-h&quot;</span>, <span style="color:#996600;">&quot;--help&quot;</span>, <span style="color:#996600;">&quot;Show this message&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
	              <span style="color:#CC0066; font-weight:bold;">puts</span> opts
	              <span style="color:#CC0066; font-weight:bold;">exit</span>
	        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	opts.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span>ARGV<span style="color:#006600; font-weight:bold;">&#41;</span>
	Main.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>options<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">run</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


	<p id="fn17652672094afa121430a8f" class="footnote"><sup>1</sup> At the moment, it &#8216;OR&#8217;s together multiple regexps on a single feed, but I&#8217;m thinking I may change that so it&#8217;s easier to <em>exclude</em> certain matches as well as <em>include</em>.</p><img src="http://feeds.feedburner.com/~r/ethelred/~4/6F-Xjg78VpA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ethelred.org/articles/2009/06/19/dns323-podcast-and-torrent-downloader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pulseaudio discoveries</title>
		<link>http://www.ethelred.org/articles/2009/06/05/pulseaudio-discoveries/</link>
		<comments>http://www.ethelred.org/articles/2009/06/05/pulseaudio-discoveries/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 12:24:52 +0000</pubDate>
		<dc:creator>Edward</dc:creator>
				<category><![CDATA[frustration]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.ethelred.org/articles/2009/06/05/pulseaudio-discoveries/</guid>
		<description><![CDATA[	
		Found out that PulseAudio includes built in support for creating multicast RTP streams of whatever audio you may be playing on your computer. 
	
	
		Then I found out if I turn on such a stream, it eats all the wireless bandwidth in the house and my wife complains her internet isn&#8217;t working. Nix that idea&#8230;
	]]></description>
			<content:encoded><![CDATA[	<ul>
		<li>Found out that <a href="http://www.pulseaudio.org/">PulseAudio</a> includes built in support for creating multicast <span class="caps">RTP</span> streams of whatever audio you may be playing on your computer. </li>
	</ul>
	<ul>
		<li>Then I found out if I turn on such a stream, it eats all the wireless bandwidth in the house and my wife complains her internet isn&#8217;t working. Nix that idea&#8230;</li>
	</ul><img src="http://feeds.feedburner.com/~r/ethelred/~4/4H-B46nHt8w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ethelred.org/articles/2009/06/05/pulseaudio-discoveries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>kill 1</title>
		<link>http://www.ethelred.org/articles/2009/06/02/kill-1/</link>
		<comments>http://www.ethelred.org/articles/2009/06/02/kill-1/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 16:52:34 +0000</pubDate>
		<dc:creator>Edward</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.ethelred.org/articles/2009/06/02/kill-1/</guid>
		<description><![CDATA[	I started wondering what would happen if I


kill -9 1


	But I have enough of a guess that I don&#8217;t want to do it while my computer is doing anything else   Maybe later.]]></description>
			<content:encoded><![CDATA[	<p>I started wondering what would happen if I</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #660033;">-9</span> <span style="color: #000000;">1</span></pre></div></div>


	<p>But I have enough of a guess that I don&#8217;t want to do it while my computer is doing anything else <img src='http://www.ethelred.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Maybe later.</p><img src="http://feeds.feedburner.com/~r/ethelred/~4/GV4rMX3Th0o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ethelred.org/articles/2009/06/02/kill-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>garden data</title>
		<link>http://www.ethelred.org/articles/2009/04/02/garden-data/</link>
		<comments>http://www.ethelred.org/articles/2009/04/02/garden-data/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 20:31:41 +0000</pubDate>
		<dc:creator>Edward</dc:creator>
				<category><![CDATA[garden]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.ethelred.org/articles/2009/04/02/garden-data/</guid>
		<description><![CDATA[	More garden-related geekery

	We&#8217;ve started planting seeds in our vegetable beds, so naturally wanted to keep a record of what is where, and since when. Hence, Garden of Ethelred

	It&#8217;s a fairly simple site &#8211; the data is in an xml file, and we have xsl transforms for the different pages. We chose xml because my wife [...]]]></description>
			<content:encoded><![CDATA[	<p><em>More <a href="http://www.ethelred.org/articles/2009/03/01/gardening-by-numbers/">garden-related</a> geekery</em></p>

	<p>We&#8217;ve started planting seeds in our vegetable beds, so naturally wanted to keep a record of what is where, and since when. Hence, <a href="http://garden.ethelred.org">Garden of Ethelred</a></p>

	<p>It&#8217;s a fairly simple site &#8211; the data is in an xml file, and we have xsl transforms for the different pages. We chose xml because my wife is familiar enough with it to make changes too.</p>

	<p>On the main hosting site I run a short <span class="caps">PHP</span> script which uses the XsltProcessor class. For testing on the home server the setup is more &#8216;fun&#8217; &#8211; a <span class="caps">CGI</span> shell script which calls <code>xsltproc</code>. I&#8217;m not sure why I&#8217;m quite so amused at writing <span class="caps">CGI</span> as shell script, but I am.</p><img src="http://feeds.feedburner.com/~r/ethelred/~4/AbwAjAOj9aY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ethelred.org/articles/2009/04/02/garden-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>screen grab logging</title>
		<link>http://www.ethelred.org/articles/2009/03/19/screen-grab-logging/</link>
		<comments>http://www.ethelred.org/articles/2009/03/19/screen-grab-logging/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 14:54:44 +0000</pubDate>
		<dc:creator>Edward</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.ethelred.org/articles/2009/03/19/screen-grab-logging/</guid>
		<description><![CDATA[	This is more of a short-term workaround than a solution, but it&#8217;s kind of fun.

	I&#8217;m doing some performance testing of one of our java servers, and I want my test to run in the night while I&#8217;m asleep. The test has previously been run using jconsole to get graphs of memory and thread usage. This [...]]]></description>
			<content:encoded><![CDATA[	<p>This is more of a short-term workaround than a solution, but it&#8217;s kind of fun.</p>

	<p>I&#8217;m doing some performance testing of one of our java servers, and I want my test to run in the night while I&#8217;m asleep. The test has previously been run using <a href="http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html">jconsole</a> to get graphs of memory and thread usage. This looks good but it&#8217;s a <span class="caps">GUI</span> only tool so not scriptable. I figured I could run it and get some screen captures.</p>

	<p><code>import</code> from <a href="http://www.imagemagick.org/">ImageMagick</a> is a tool for doing screen grabs from a script. However it needs an X11 window ID to grab a window, which can be a little tricky to find. Another problem I found when testing was that if I had another window overlapping the window I was grabbing, that part came out black, and when the screensaver kicked in, the scripted grab didn&#8217;t work.</p>

	<p>Taking these problems, I came up with my workaround. First, run a vncserver, so that jconsole is in a separate display which isn&#8217;t affected by other windows or the screensaver. I also set the geometry to have just enough room for the windows I want.</p>

<pre>
vncserver -geometry 1000x1500 :1
</pre>

	<p>Connect to this with a vncviewer, start up <code>jconsole</code> and set it up to display what I&#8217;m interested in.</p>

	<p>Now I can start my test, and run my <code>windowdump</code> script:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">dumpdir</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>edward<span style="color: #000000; font-weight: bold;">/</span>screencaps
<span style="color: #007800;">wingrep</span>=Monitoring
&nbsp;
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">true</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #007800;">pdate</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>Y<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>d_<span style="color: #000000; font-weight: bold;">%</span>H<span style="color: #000000; font-weight: bold;">%</span>M<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #000000; font-weight: bold;">for</span> winid <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>xwininfo <span style="color: #660033;">-display</span> :<span style="color: #000000;">1</span> <span style="color: #660033;">-root</span> <span style="color: #660033;">-tree</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$wingrep</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #660033;">-s</span> <span style="color: #ff0000;">' '</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-d</span><span style="color: #ff0000;">' '</span> -f2<span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span>
        import <span style="color: #660033;">-display</span> :<span style="color: #000000;">1</span> <span style="color: #660033;">-silent</span> <span style="color: #660033;">-frame</span> <span style="color: #660033;">-window</span> <span style="color: #007800;">$winid</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${dumpdir}</span>/<span style="color: #007800;">${wingrep}</span>_<span style="color: #007800;">${winid}</span>_<span style="color: #007800;">${pdate}</span>.png&quot;</span>
    <span style="color: #000000; font-weight: bold;">done</span>
    <span style="color: #c20cb9; font-weight: bold;">sleep</span> 30m
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>


	<p>This uses <code>xwininfo</code> to grab all windows in the display, then <code>grep</code> and <code>cut</code> to get the IDs of the ones I&#8217;m interested in, and pass those to <code>import</code> to grab them. </p>

	<p>Quite silly really. If I have time I&#8217;ll be writing some code to just read numbers from <span class="caps">JMX</span> and log them to a file.</p><img src="http://feeds.feedburner.com/~r/ethelred/~4/0df-RXBLysQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ethelred.org/articles/2009/03/19/screen-grab-logging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
