<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom"
  >
<channel>
<title>Tim Hatch</title>
<link>http://timhatch.com/</link>
<atom:link href="http://timhatch.com/feed/rss" rel="self" type="application/rss+xml" />
<description>Web journal of Tim Hatch, programmer, web designer, and panorama photographer</description>
<!--<updated>2010-03-12T07:50:22Z</updated>-->
<item>
  <title>Equivalent of os.path.abspath in bash</title>
  <guid isPermaLink="true">http://timhatch.com/ark/2010/03/08/equivalent-of-os-path-abspath-in-bash</guid>
  <link>http://timhatch.com/ark/2010/03/08/equivalent-of-os-path-abspath-in-bash</link>
  <content:encoded><![CDATA[<p>I don&#8217;t know how many times I&#8217;ve written a script that takes a directory argument, but I want to store that as an absolute path because I&#8217;ll be changing directories a lot.  I had tens of lines of code to tack on <code>$PWD</code> with lots of conditions, but last week it finally hit me:</p>

<pre>fullpath="$(cd "$1"; pwd)"</pre>

<p>It will also give you the path with <code>../</code> removed.</p>]]></content:encoded>
  <pubDate>Mon, 08 Mar 2010 13:00:40 -0800</pubDate>
</item>
<item>
  <title>OpenSSH return codes</title>
  <guid isPermaLink="true">http://timhatch.com/ark/2010/02/18/openssh-return-codes</guid>
  <link>http://timhatch.com/ark/2010/02/18/openssh-return-codes</link>
  <content:encoded><![CDATA[<p>I&#8217;ve used openssh for many years, and dropbear for about two.  Today I ran into a problem that was intermittently failing.  I have an upgrade script that essentially boils down to:</p>

<pre>
ssh device do_stuff
ssh webservice change_something
ssh device udpate_config
</pre>

<p>At the top of my script, I want to make sure that an ssh agent is set up and the device has my public key, so I also include:</p>

<pre>
ssh -o 'batchmode yes' device 'exit 0'
</pre>

<p>With the versions I&#8217;m using 
(OpenSSH_5.2p1 to a dropbear v0.50 server), this is fundamentally broken, returning <code>255</code> most of the time and <code>0</code> every now and then.  A workaround, in case you hit this too:</p>

<pre>
ssh -o 'batchmode yes' device 'echo Works' | grep -q Works
</pre>

<p>This preserves the <code>$?</code> being <code>0</code> for success, and nonzero otherwise.</p>
]]></content:encoded>
  <pubDate>Thu, 18 Feb 2010 19:51:39 -0800</pubDate>
</item>
<item>
  <title>Eagle freeware upgrade</title>
  <guid isPermaLink="true">http://timhatch.com/ark/2010/01/26/eagle-freeware-upgrade</guid>
  <link>http://timhatch.com/ark/2010/01/26/eagle-freeware-upgrade</link>
  <content:encoded><![CDATA[<p>If you upgrade your version of Eagle freeware on OS X, and it continually asks for a license key, the file you need to remove is <code>/Applications/EAGLE/bin/EAGLE.key</code>.  Other prefs (say, if windows get saved offscreen) are stored in <code>~/Library/Preferences/EAGLE.plist</code>.</p>]]></content:encoded>
  <pubDate>Tue, 26 Jan 2010 15:47:16 -0800</pubDate>
</item>
<item>
  <title>Grepping for Processes</title>
  <guid isPermaLink="true">http://timhatch.com/ark/2009/10/21/grepping-for-processes</guid>
  <link>http://timhatch.com/ark/2009/10/21/grepping-for-processes</link>
  <content:encoded><![CDATA[<p>I learned something new today.  Instead of doing</p>

<pre>ps auxw | grep procname | grep -v grep</pre>

<p>you can just do</p>

<pre>ps auxw | grep [p]rocname</pre>

<p>since the grep process itself will show up with punctuation in ps.</p>

<p>&#8212; via <a href="http://gist.github.com/208588">github</a>.</p>]]></content:encoded>
  <pubDate>Wed, 21 Oct 2009 17:04:07 -0700</pubDate>
</item>
<item>
  <title>rrdtool graphing script</title>
  <guid isPermaLink="true">http://timhatch.com/ark/2009/10/20/rrdtool-graphing-script</guid>
  <link>http://timhatch.com/ark/2009/10/20/rrdtool-graphing-script</link>
  <content:encoded><![CDATA[<p>If you&#8217;d like a copy of a pretty straightforward rrdtool frontend script, I&#8217;ve put online the one that I use at home and work for your enjoyment.  It's called <a href="http://timhatch.com/projects/rrdgraphs/">rrdgraphs</a>.</p>

<img src="http://timhatch.com/db/posts/2009-10-20.04/rrdgraphs.png" width="681" height="490" alt="" />
]]></content:encoded>
  <pubDate>Tue, 20 Oct 2009 21:48:13 -0700</pubDate>
</item>
<item>
  <title>Open Source and Crashing</title>
  <guid isPermaLink="true">http://timhatch.com/ark/2009/10/20/open-source-and-crashing</guid>
  <link>http://timhatch.com/ark/2009/10/20/open-source-and-crashing</link>
  <content:encoded><![CDATA[<p>At $JOB we use a lot of open source technology.  Our servers run Linux, our
dev machines (generally) run Linux, our core products are written with Ruby on
Rails and a lot of Python (some Django, not much).
</p>

<p>Consequently we do a lot of editing text, and that editing happens without
an IDE because that&#8217;s easier to do remotely (or maybe we&#8217;re just stuck in our
ways).  For the Ruby guys, that means Textmate and a little bit of classic vi;
for the Python folks gVim/CarbonEmacs (all on OS X).  Strangely enough, most
of the worst crashes all seem tied to editors (but maybe that&#8217;s just because
we have them open all the time, just like how 90% of accidents occur within a
mile of home).  I&#8217;m about to downgrade from Snow Leopard because of other
<a href="http://openradar.appspot.com/7210360">minor glitches with
    Spotlight</a> but Berto&#8217;s been hitting kernel panics only when CarbonEmacs
is open.</p>

<img src="http://timhatch.com/db/posts/2009-10-20.03/sadsnowleopard.jpg" width="700" height="525"
alt="Berto taking a picture of a kernel panic" />

<p>Funny, huh? Not for the second time in a day.  And it turns out that Apple Engineering is investigating both of our issues, but nothing yet.  At least they&#8217;re not duplicates of &#8220;existing issues.&#8221;</p>
]]></content:encoded>
  <pubDate>Tue, 20 Oct 2009 21:31:04 -0700</pubDate>
</item>
<item>
  <title>A Simpler Loopback Cable</title>
  <guid isPermaLink="true">http://timhatch.com/ark/2009/10/20/a-simpler-loopback-cable</guid>
  <link>http://timhatch.com/ark/2009/10/20/a-simpler-loopback-cable</link>
  <content:encoded><![CDATA[<p>Earlier today I <a href="http://timhatch.com/ark/2009/10/20/how-to-make-a-serial-loopback-cable">posted some info</a> on a double-loopback cable I made earlier this year.  If you relax the requirement that the ends be different vendors, it's possible to make a much simpler one.</p>

<img src="http://timhatch.com/db/posts/2009-10-20.02/ftdiloopback.jpg" width="700" height="346" alt="" />

<p>This cable has the TX/RX cris-crossed, and the grounds connected.  That's technically all that's required for something like this, all without custom circuitry.  Note that on this picture, black is at the top of both cables.</p>]]></content:encoded>
  <pubDate>Tue, 20 Oct 2009 21:08:56 -0700</pubDate>
</item>
<item>
  <title>How to Make a Serial Loopback Cable</title>
  <guid isPermaLink="true">http://timhatch.com/ark/2009/10/20/how-to-make-a-serial-loopback-cable</guid>
  <link>http://timhatch.com/ark/2009/10/20/how-to-make-a-serial-loopback-cable</link>
  <content:encoded><![CDATA[<p>A regular loopback serial cable just ties the Tx and Rx lines, so any characters you send are echoed back on the receive side.  For a special project, I needed one that tied together two whole bidirectional ports so I could connect a piece of software that wanted to use a serial port with another that emulated responses for testing.  Here's the frankencable I came up with a couple of weeks ago.</p>

<h4>Requirements</h4>

<ul>
    <li>Be built with only parts on hand (that is, in my toolbox at the
    office, or things I regularly keep in my car, which has more of the same)</li>
    <li>Consist of two different USB-Serial chip vendors, for easy
    differentiation with udev rules</li>
    <li>Work out-of-the-box on most 2.6 Linux kernels (so the Keyspan 4-port
    adapter is automatically out, with the <a
        href="https://bugs.launchpad.net/ubuntu/+source/linux/+bug/149649">Ubuntu
        8.x bug 149649</a>)</li>
    <li>End goal: write data into one usb-serial device and be able to read it
    out of the other, on the same machine.</li>
</ul>

<p>This ended up being a pretty quick rummage.  The only devices handy were
two <a href="http://www.ftdichip.com/Products/EvaluationKits/TTL-232R.htm">FTDI TTL232</a>
which are TTL-level, and a bunch of Prolific PL2303-based RS232-level chips.
The handy MAX232 does this conversion, but I didn#8217;t have time to prototype a
board...</p>

<p>But the RepRap to the rescue.  I had one of the <a
    href="http://reprap.org/bin/view/Main/PowerCommsBoard_1_3">old comms
    boards</a> which had
a MAX232 on it, but it would need a computer PSU to provide power,
except...</p>

<p>It needs 5v which the FTDI cable can already provide.</p>

<p>A few jumpers, a spare servo cable, and some trial and error (I always
forget whose perspective Tx and Rx are from) later, we have this wonderful
gadget (where every connection is pretty much wired backwards from intended):</p>

<img src="http://timhatch.com/db/posts/2009-10-20.01/2009-09-25-13.44.26.jpg" width="700"
height="525" alt="" />
]]></content:encoded>
  <pubDate>Tue, 20 Oct 2009 20:59:02 -0700</pubDate>
</item>
</channel>
</rss>
