<?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>And now it’s all this</title>
	<atom:link href="http://www.leancrew.com/all-this/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.leancrew.com/all-this</link>
	<description>I just said what I said and it was wrong. Or was taken wrong.</description>
	<lastBuildDate>Thu, 17 May 2012 05:35:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>XSLT, of course</title>
		<link>http://www.leancrew.com/all-this/2012/05/xslt-of-course/</link>
		<comments>http://www.leancrew.com/all-this/2012/05/xslt-of-course/#comments</comments>
		<pubDate>Thu, 17 May 2012 05:35:13 +0000</pubDate>
		<dc:creator>Dr. Drang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[podcasts]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[xslt]]></category>

		<guid isPermaLink="false">http://www.leancrew.com/all-this/?p=1838</guid>
		<description><![CDATA[A couple of days ago, I stole Jason Snell&#8217;s idea of using Yahoo! Pipes to filter the 5by5 After Dark podcast feed to limit it to just the After Darks of shows I listen to. In the first comment on the post, Gabe (Macdrifter) asked whether it was a good idea to rely on Yahoo!&#8230;]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago, <a href="http://www.leancrew.com/all-this/2012/05/stealing-ideas/">I stole Jason Snell&#8217;s idea</a> of using <a href="http://pipes.yahoo.com">Yahoo! Pipes</a> to filter the 5by5 After Dark podcast feed to limit it to just the After Darks of shows I listen to. In the <a href="http://www.leancrew.com/all-this/2012/05/stealing-ideas/#comment-20591">first comment</a> on the post, Gabe (<a href="http://www.macdrifter.com/">Macdrifter</a>) asked whether it was a good idea to rely on Yahoo! for this kind of service.</p>

<p>For reasons I can&#8217;t fully explain, I have a little more faith in Yahoo! than almost every other sentient being on the planet. Even though I can&#8217;t think of a single thing of value the Yahooers get out of Pipes, I don&#8217;t think they&#8217;ll be shutting it down anytime soon. And even if they did, losing a sightly more convenient form of a podcast feed wouldn&#8217;t drive me to the depths of despair.</p>

<p>But the notion of creating and hosting my own filtered feed <em>was</em> appealing. I asked Twitter for examples of existing libraries or frameworks that I could use for that purpose. I got a few answers, but none that I&#8217;d feel comfortable using. Using someone&#8217;s half-finished implementation in a language that only half understand does not appeal.</p>

<p>Tonight, though, I realized that a standards-compliant solution was staring me in the face: <a href="http://en.wikipedia.org/wiki/XSLT">XSLT</a>. RSS is just XML, and <em>the</em> way to filter XML is through XSLT. I&#8217;m hardly an XSLT expert, but I&#8217;d used it several years ago when I modified Fletcher Penney&#8217;s <a href="http://fletcherpenney.net/multimarkdown/">MultiMarkdown</a>, so I knew I could do it again, especially for a simple filter.</p>

<p>As a language, XSLT blows, but once you accept its absurd verbosity you can get on with life and do the job. And there are plenty of examples on the internet to crib from. I found <a href="http://www.velocityreviews.com/forums/t169353-xslt-for-filtering-xml-based-on-attribute-value.html">this one</a> to be close enough to what I was doing. I downloaded the After Dark feed and started experimenting. After several dead ends, I wound up with this:</p>

<pre><code>xml:
 1:  &lt;?xml version="1.0" encoding="utf-8" ?&gt;
 2:  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
 3:  
 4:  &lt;xsl:output method="xml" encoding="utf-8" indent="yes"/&gt;
 5:  
 6:  &lt;!-- First, get everything. --&gt;
 7:  &lt;xsl:template match="node() | @*"&gt;
 8:     &lt;xsl:copy&gt;
 9:         &lt;xsl:apply-templates select="node() | @*"/&gt;
10:     &lt;/xsl:copy&gt;
11:  &lt;/xsl:template&gt;
12:  
13:  &lt;!-- Then restrict to just certain items. --&gt;
14:  &lt;xsl:template match="/rss/channel/item"&gt;
15:     &lt;xsl:if test="title[contains(., 'Incomparable') or contains(., 'Talk Show') or contains(., 'Back to Work') or contains(., 'Hypercritical')]"&gt;
16:       &lt;item&gt;
17:         &lt;xsl:apply-templates select="node()" /&gt;
18:      &lt;/item&gt;
19:    &lt;/xsl:if&gt;
20:  &lt;/xsl:template&gt;
21:  
22:  &lt;/xsl:stylesheet&gt;
</code></pre>

<p>The pattern used here—start out with a stanza that grabs everything and then follow up with one that picks out the nodes you need—seems to be standard; I saw it in several examples. What makes it useful in this situation is that the first stanza gives you all the channel information—which you need to keep—without having to write any code specific to that structure.</p>

<p>Let&#8217;s be more concrete. Here&#8217;s the skeleton of the After Dark RSS feed:</p>

<pre><code>xml:
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:atom="http://www.w3.org/2005/Atom/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:media="http://search.yahoo.com/mrss/" version="2.0"&gt;
  &lt;channel&gt;
    &lt;title&gt;After Dark&lt;/title&gt;
    &lt;link&gt;http://5by5.tv/afterdark&lt;/link&gt;
    &lt;pubDate&gt;Wed, 16 May 2012 18:00:00 GMT&lt;/pubDate&gt;
    &lt;description&gt;This is what happens after Dan and his co-hosts hit "STOP" and their official shows are over. Behind the scenes, casual, unedited, and uncensored. Hosted by Dan Benjamin.&lt;/description&gt;
    &lt;!-- many nodes with info about the podcast in general --&gt;
    &lt;item&gt;
      &lt;title&gt;After Dark 157: After Amplified #7&lt;/title&gt;
      &lt;!-- more info about this episode --&gt;
    &lt;/item&gt;
    &lt;item&gt;
      &lt;title&gt;After Dark 156: After Back to Work #67&lt;/title&gt;
      &lt;!-- more info about this episode --&gt;
    &lt;/item&gt;
    &lt;item&gt;
      &lt;title&gt;After Dark 155: After Build and Analyze #77&lt;/title&gt;
      &lt;!-- more info about this episode --&gt;
    &lt;/item&gt;
    &lt;!-- and so on, with more items --&gt;
  &lt;/channel&gt;
&lt;/rss&gt;
</code></pre>

<p>My goal is to get everything in this feed except the <code>&lt;item&gt;</code>s for shows I   don&#8217;t listen to. I don&#8217;t care about the structure of the nodes that provide the general podcast information, I just know that I want them in the output. The &#8220;get everything&#8221; stanza in Lines 6-11 provides that.</p>

<p>Similarly, the stanza in Lines 13-20 get all the <code>&lt;item&gt;</code>s I want based entirely on what&#8217;s in their <code>&lt;title&gt;</code>s. I don&#8217;t need to know anything else about the internals of an <code>&lt;item&gt;</code>.</p>

<p>With this filter, I can generate my own After Dark feed via</p>

<pre><code>curl -s http://feeds.feedburner.com/5by5-afterdark \
 | xsltproc rssfilter.xslt - \
 | sed '/^ *$/d' &gt; afterdark.rss
</code></pre>

<p>Aren&#8217;t pipelines fun? I&#8217;ve split it over several lines to make it easier to read. The command</p>

<ol>
<li>Downloads the feed.</li>
<li>Filters it as described above.</li>
<li>Deletes the blank lines.</li>
<li>Saves it to a file.</li>
</ol>

<p>Deleting the blank lines with <code>sed</code> wasn&#8217;t really necessary, but it neatened up the output feed.</p>

<p>So what good is this? Well, if you have shell access to a server with <code>curl</code> and <code>xsltproc</code>,<sup id="fnref:curl"><a href="#fn:curl" rel="footnote">1</a></sup> you could set up a <code>cron</code> process to run this pipeline periodically and then subscribe to that <code>afterdark.rss</code> file. If you don&#8217;t have shell access on your server, you can set up a schedule to run the pipeline locally and upload the resulting file.</p>

<p>Either way, you have a filtered feed that doesn&#8217;t rely on a free online service that could be yanked at any time and which only uses standard tools.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:curl">
<p>Or equivalent programs.&#160;<a href="#fnref:curl" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.leancrew.com/all-this/2012/05/xslt-of-course/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enhancing screenshots with PIL</title>
		<link>http://www.leancrew.com/all-this/2012/05/enhancing-screenshots-with-pil/</link>
		<comments>http://www.leancrew.com/all-this/2012/05/enhancing-screenshots-with-pil/#comments</comments>
		<pubDate>Wed, 16 May 2012 02:16:09 +0000</pubDate>
		<dc:creator>Dr. Drang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[pil]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[screenshots]]></category>

		<guid isPermaLink="false">http://www.leancrew.com/all-this/?p=1837</guid>
		<description><![CDATA[When I wrote a post last week about using Flickr as a CDN, there was a paragraph that bothered me: One thing did change when I started using Flickr to host screenshots: I had to change my screenshot format from PNG to JPEG. Flickr accepts PNGs, but it saves the resized images as JPEGs, and&#8230;]]></description>
			<content:encoded><![CDATA[<p>When I wrote a post last week about <a href="http://www.leancrew.com/all-this/2012/05/flickr-as-a-poor-mans-cdn/">using Flickr as a CDN</a>, there was a paragraph that bothered me:</p>

<blockquote>
  <p>One thing did change when I started using Flickr to host screenshots: I had to change my screenshot format from PNG to JPEG. Flickr accepts PNGs, but it saves the resized images as JPEGs, and any transparent areas in the original PNG become black in the resized JPEGs. Since many of my screenshots are of windows with the semi-transparent shadow, the resized versions on Flickr look like shit. With JPEG screenshots, the window shadow backgrounds are white, which is just what I want.</p>
</blockquote>

<p>While a white background to the window shadow is generally OK when I include a screenshot here, it isn&#8217;t always &#8220;just what I want.&#8221; For example, when I want to put a window screenshot in an update to a post, the white background of the screenshot looks stupid against the light green of the update <code>&lt;div&gt;</code>. And when I need to mix screenshots of multiple windows with those of single windows, there&#8217;s a clash of styles because my multiple window screenshots usually have a bit of my Desktop color (Solid Aqua Dark Blue) showing.<sup id="fnref:backdrop"><a href="#fn:backdrop" rel="footnote">1</a></sup></p>

<p>Unfortunately, the <a href="https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/screencapture.1.html"><code>screencapture</code> command</a>, which my <a href="https://github.com/drdrang/flickr-stuff"><code>snapflickr</code> program</a> calls, doesn&#8217;t have an option to layer in a background color. So I needed to do the layering myself. Since <code>snapflickr</code> is written in Python, the natural way to add the background is through the <a href="http://www.pythonware.com/products/pil/">Python Imaging Library</a> (PIL).</p>

<p>I was a little apprehensive. I&#8217;ve used PIL several times in the past and never had any real trouble installing it, but I hadn&#8217;t installed it under Lion, and in particular I hadn&#8217;t installed it under Lion after Xcode moved from <code>/Developer</code> to <code>/Applications</code>. Gabe Weatherhead (<a href="http://www.macdrifter.com/">Macdrifter</a>) has tweeted recently about the problems he had getting PIL installed, and I was not inclined to follow in his footsteps (he eventually got it installed via Macports, a system I never want to see again). The comments on <a href="http://nyteshade.posterous.com/macos-x-107x-python-27-and-pil">this post</a> suggest that Apple&#8217;s movement of Xcode, combined with the fact that it no longer installs the command line tools with Xcode by default, has turned the installation of PIL into an almost superhuman effort.</p>

<p>But I really wanted that background color in my screenshots, and I didn&#8217;t want to do it through AppleScripting <a href="http://itunes.apple.com/us/app/acorn-image-editor-for-humans/id402280036?mt=12&amp;partnerId=30&amp;siteID=L4JhWyGwYTM">Acorn</a> if I could help it. So I started by installing the Command Line Tools through Xcode&#8217;s Preferences:</p>

<p><a href="http://www.flickr.com/photos/drdrang/7206483848/"><img class="ss" src="http://farm6.staticflickr.com/5114/7206483848_38d4d2385a_z.jpg" alt="Xcode Download Preferences" title="Xcode Download Preferences" /></a></p>

<p>Then I crossed my fingers and typed</p>

<pre><code>sudo easy_install pil
</code></pre>

<p>It worked on the first try! Oh, there were compilation warnings aplenty, most of which had to do with casting 32-bit values as 64-bit (or something like that, I didn&#8217;t save them), but when I was done, I had a PIL that was usable. Apparently, PIL just likes me better than it likes Gabe.</p>

<p>The right library makes all the difference in the world. Adding a background to my screenshots was very easy with PIL. Here are the lines I had to add to <code>snapflickr</code>:</p>

<pre><code> 95: # Add a desktop background if it's a shadowed window screenshot.
 96: snap = Image.open(fn)
 97: if snap.mode == 'RGBA':
 98:   # Crop it to a more reasonable size, 
 99:   # and paste it over a solid-colored background.
100:   cropbox = (margin[0],
101:              margin[1],
102:              snap.size[0]-margin[2],
103:              snap.size[1]-margin[3])
104:   snap = snap.crop(cropbox)
105:   bg = Image.new('RGB', snap.size, bgcolor)
106:   bg.paste(snap, None, snap)
107:   bg.save(fn)
</code></pre>

<p>We start on Line 96 by opening the screenshot, which has already been saved to the Desktop as a PNG file and has been given the name stored in the <code>fn</code> variable. Since I want to add the background color only to window screenshots, and window screenshots in PNG format have an alpha channel to handle the shadow transparency, the test on Line 97 will return true only for window screenshots. The remaining lines will be skipped for rectangular area screenshots.</p>

<p>I like the shadow Apple adds to windows, but when you take a screenshot with a shadow, there&#8217;s a lot of extra margin beyond the shadow itself. Lines 100-104 crop out the extra using a <code>margin</code> tuple defined earlier in the program as</p>

<pre><code>margin = (25, 5, 25, 35)
</code></pre>

<p>These are how many pixels get cropped off the left, top, right, and bottom sides. I chose them after a bit of experimentation because I thought they gave a decent look to the result.</p>

<p>Line 105 creates a solid background image of the same size as the newly-cropped screenshot and filled with the color defined near the top of the program as</p>

<pre><code>bgcolor = (61, 101, 156)
</code></pre>

<p>which are the decimal RGB values for Solid Aqua Dark Blue.</p>

<p>Line 106 pastes the screenshot on top of the background. The third argument to <code>paste</code> is the mask. According to the <a href="http://www.pythonware.com/library/pil/handbook/image.htm">PIL documentation</a>, calling <code>paste</code> with three arguments</p>

<blockquote>
  <p>updates only the regions indicated by the mask. You can use either &#8220;1&#8221;, &#8220;L&#8221; or &#8220;RGBA&#8221; images (in the latter case, the alpha band is used as mask).</p>
</blockquote>

<p>So using <code>snap</code> as both the source and the mask is like using two layers in a program like Photoshop or Acorn. The screenshot is set in a layer in front of the background layer, which is visible through the transparent parts. The image is then flattened into a single layer.</p>

<p>The new image with the background color is then saved, overwriting the original screenshot. Because the <code>bg</code> image is in RGB mode (no alpha channel), so is the saved image. When the image is uploaded to Flickr, the original size will be a PNG and all the other sizes will be JPEGs, but there&#8217;ll be no funny black background areas in the resized images because Flickr won&#8217;t have to deal with transparency in the original.</p>

<p>It&#8217;s entirely possible that I&#8217;ll fiddle around some more with the margins, trying different crop amounts to see if I like something better. But I think the basic structure of the code is set.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:backdrop">
<p>Actually, what&#8217;s usually showing in a multi-window screenshot is <a href="http://itunes.apple.com/us/app/backdrop/id411461952?mt=12&amp;partnerId=30&amp;siteID=L4JhWyGwYTM">Backdrop</a>. Although I like to keep a tidy Desktop, there are usually at least a few icons on it. Backdrop is an app that covers up the Desktop—and any app windows it&#8217;s stacked in front of—with a nice solid color. Great for screenshots and screencasts.&#160;<a href="#fnref:backdrop" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.leancrew.com/all-this/2012/05/enhancing-screenshots-with-pil/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Stealing ideas</title>
		<link>http://www.leancrew.com/all-this/2012/05/stealing-ideas/</link>
		<comments>http://www.leancrew.com/all-this/2012/05/stealing-ideas/#comments</comments>
		<pubDate>Tue, 15 May 2012 03:24:14 +0000</pubDate>
		<dc:creator>Dr. Drang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[podcasts]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[yahoo pipes]]></category>

		<guid isPermaLink="false">http://www.leancrew.com/all-this/?p=1836</guid>
		<description><![CDATA[Tonight I saw these two tweets from Jason Snell and smacked my forehead. Of course! The &#8220;Smart Playlists&#8221; feature in Instacast 2 isn&#8217;t smart. I&#8217;d like only @5by5 After Darks from certain podcasts, but it can&#8217;t filter that.&#160;&#160;&#8212; Jason Snell (@jsnell) Mon May 14 2012 (Solution: I made a Yahoo Pipe that takes in the&#8230;]]></description>
			<content:encoded><![CDATA[<p>Tonight I saw these two tweets from <a href="https://twitter.com/#!/jsnell">Jason Snell</a> and smacked my forehead. Of course!</p>

<div class="bbpBox" id="t202204607248740353"><blockquote><span class="twContent">The &#8220;Smart Playlists&#8221; feature in Instacast 2 isn&#8217;t smart. I&#8217;d like only <a href="http://twitter.com/5by5">@5by5</a> After Darks from certain podcasts, but it can&#8217;t filter that.</span><span class="twMeta"><br /><span class="twDecoration">&nbsp;&nbsp;&mdash; </span><span class="twRealName">Jason Snell</span><span class="twDecoration"> (</span><a href="http://twitter.com/jsnell"><span class="twScreenName">@jsnell</span></a><span class="twDecoration">) </span><a href="https://twitter.com/#!/jsnell/statuses/202204607248740353"><span class="twTimeStamp">Mon May 14 2012</span></a><span class="twDecoration"></span></span></blockquote></div>

<div class="bbpBox" id="t202208384236261376"><blockquote><span class="twContent">(Solution: I made a Yahoo Pipe that takes in the After Dark feed, filters by show title, and then outputs a new RSS feed.)</span><span class="twMeta"><br /><span class="twDecoration">&nbsp;&nbsp;&mdash; </span><span class="twRealName">Jason Snell</span><span class="twDecoration"> (</span><a href="http://twitter.com/jsnell"><span class="twScreenName">@jsnell</span></a><span class="twDecoration">) </span><a href="https://twitter.com/#!/jsnell/statuses/202208384236261376"><span class="twTimeStamp">Mon May 14 2012</span></a><span class="twDecoration"></span></span></blockquote></div>

<p>The After Dark feed includes After Darks from all the <a href="http://5by5.tv">5by5 shows</a>. This is probably a good way for Dan Benjamin to introduce all his shows to those who currently listen to just a couple (and it&#8217;s certainly easier to manage one After Dark feed than a dozen), but I&#8217;ve had to declare podcast bankruptcy<sup id="fnref:bankruptcy"><a href="#fn:bankruptcy" rel="footnote">1</a></sup> more than once and don&#8217;t need any more suggestions.</p>

<p>Hence the value of Jason&#8217;s tweets. <a href="http://pipes.yahoo.com">Yahoo! Pipes</a>, which was big news four or five years ago, is still there and still working, but I never would&#8217;ve thought of it, even though it&#8217;s absolutely perfect for this sort of situation. It&#8217;s hard to imagine how Yahoo! makes any money off of Pipes, but as long as it&#8217;s there, we should take advantage.</p>

<p>I&#8217;m not privy to what Jason&#8217;s After Dark pipe looks like, but here&#8217;s mine:</p>

<p><a href="http://www.flickr.com/photos/drdrang/7200534982/"><img class="ss" src="http://farm8.staticflickr.com/7225/7200534982_8647859194_o.jpg" alt="5by5 After Dark Pipe" title="5by5 After Dark Pipe" /></a></p>

<p>This is about as simple as a Pipe can get. The original feed is</p>

<pre><code>http://feeds.feedburner.com/5by5-afterdark
</code></pre>

<p>and I allow only those items whose titles contain the key title words of the podcasts I listen to. I should probably add <a href="http://macpowerusers.com/">Mac Power Users</a> to the list, even though it&#8217;s never had an After Dark—there&#8217;s always a first time.</p>

<p>Sometimes you don&#8217;t need chapter and verse; just a word or two is sufficient. My thanks to Jason for providing the words.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:bankruptcy">
<p>You know, like <a href="http://en.wikipedia.org/wiki/Email_bankruptcy">email bankruptcy</a>, but with podcasts.&#160;<a href="#fnref:bankruptcy" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.leancrew.com/all-this/2012/05/stealing-ideas/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Links</title>
		<link>http://www.leancrew.com/all-this/2012/05/links/</link>
		<comments>http://www.leancrew.com/all-this/2012/05/links/#comments</comments>
		<pubDate>Mon, 14 May 2012 04:43:52 +0000</pubDate>
		<dc:creator>Dr. Drang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[blogging]]></category>

		<guid isPermaLink="false">http://www.leancrew.com/all-this/?p=1834</guid>
		<description><![CDATA[Last week I was going to write a post about Leslie speakers. My hook was going to be the use of &#8220;Tomorrow Never Knows&#8221; in last week&#8217;s episode of Mad Men. A famous story about the recording of &#8220;Tomorrow Never Knows&#8221; is that John&#8217;s voice was fed through a Leslie speaker to get that ethereal&#8230;]]></description>
			<content:encoded><![CDATA[<p>Last week I was going to write a post about <a href="http://en.wikipedia.org/wiki/Leslie_speaker">Leslie speakers</a>. My hook was going to be the use of &#8220;<a href="http://en.wikipedia.org/wiki/Tomorrow_Never_Knows">Tomorrow Never Knows</a>&#8221; in <a href="http://artsbeat.blogs.nytimes.com/2012/05/07/how-mad-men-landed-the-beatles-all-you-need-is-love-and-250000/">last week&#8217;s episode of <em>Mad Men</em></a>. A famous story about the recording of &#8220;Tomorrow Never Knows&#8221; is that John&#8217;s voice was fed through a Leslie speaker to get that ethereal sound. This was in lieu of</p>

<ol>
<li>a chorus of Tibetan monks, or</li>
<li>suspending John from a rope tied to the ceiling and spinning him around as he sang,</li>
</ol>

<p>both of which were John&#8217;s ideas.</p>

<p>Leslie speakers were one of the many clever audio devices that people came up with the the pre-digital age. Inventors had to be clever back then because you couldn&#8217;t just throw massive amounts of computing power at a problem to get a solution. The Leslie <a href="http://theatreorgans.com/hammond/faq/mystery/mystery.html">achieved its unique sound</a> by spinning its speakers around to get both a tremolo, because volume changed as the speakers went from pointing toward you to pointing away from you, and a vibrato due to the Doppler effect.</p>

<p><a href="http://www.flickr.com/photos/drdrang/7193549688/"><img class="ss" src="http://farm8.staticflickr.com/7239/7193549688_9268f9a06f_o.jpg" alt="Leslie treble speaker" title="Leslie treble speaker" /></a></p>

<p style="text-align:right;font-size:80%">(Image taken from <a href="http://theatreorgans.com/hammond/faq/mystery/mystery.html">Clifford Hendricksen article</a>.)</p>

<p>It&#8217;s hard, though, to write an article about the Leslie without also writing about the <a href="http://en.wikipedia.org/wiki/Hammond_organ">Hammond tonewheel organ</a>, with which it was usually paired. In fact, there was no microphone input to the Leslie at Abbey Road; it was so intimately tied to the Hammond that the engineers had to open up the speaker cabinet to wire the mic in directly.</p>

<p>The Hammond was perhaps an <a href="http://b3world.com/hammond-techinfo.html">even greater example</a> of pre-digital cleverness. It was, in effect, an electromechanical synthesizer, generating pure tones in harmonic series that were added together to create particular timbres. The pure tones were made by spinning toothed wheels—gears, basically—in front of electromagnetic pickups. The spinning gear changed the magnetic field in a regular, sinusoidal pattern, inducing a sinusoidal current in the pickup&#8217;s coil. If this sounds suspiciously like the way an electric guitar works, it&#8217;s because it is, with the spinning gear taking the place of the vibrating string. In fact, it&#8217;s so much like an electric guitar, you&#8217;d think it would&#8217;ve been invented by <a href="http://www.lespaulonline.com/">Les Paul</a>.</p>

<p><a href="http://www.flickr.com/photos/drdrang/7193549096/in/photostream/"><img class="ss" src="http://farm8.staticflickr.com/7104/7193549096_fa0bbb03f3_o.jpg" alt="Hammond tone wheel" title="Hammond tone wheel" /></a></p>

<p style="text-align:right;font-size:80%">(Image taken from <a href="http://b3world.com/hammond-techinfo.html">Keyboard Exchange International</a>.)</p>

<p>The organist had great control over how the harmonics were added through the manipulation of a series of drawbars. The similarity between the drawbars on a Hammond and the stops on a <a href="http://en.wikipedia.org/wiki/Pipe_organ">pipe organ</a> can&#8217;t be coincidental. The Hammond was, and still is, marketed largely to churches who want that churchy organ sound but can&#8217;t afford a pipe organ.</p>

<p>Soon, the Hammond sound, especially the B3 model, worked its way into blues, R&amp;B, and rock and roll. My article got sidetracked for a day or two as I spent hours on YouTube looking at videos of <a href="http://www.youtube.com/watch?v=N0FuFfcCZiE">Keith Emerson</a>, <a href="http://www.youtube.com/watch?v=qZBc-RLN1vE">Jon Lord</a>, <a href="http://www.youtube.com/watch?v=i_m-gyi5Fno">Jimmy Smith</a>, <a href="http://www.youtube.com/watch?v=DuvB02dHylM">Gregg Rolie</a>, and <a href="http://www.youtube.com/watch?v=-L6qjwbklAQ">Rod Argent</a>. Research, don&#8217;t you know.</p>

<p>This morning I woke up to the news that Duck Dunn had died, leaving only half of <a href="http://en.wikipedia.org/wiki/Booker_T._and_the_MGs">the great Stax house band</a> still with us. I doubt more than a week ever goes by without me listening to <a href="http://www.duckdunn.com/discography.html">at least one song with Dunn on it</a>.</p>

<p>I don&#8217;t think I&#8217;ll ever write that Tomorrow Never Knows/Leslie/Hammond post. As with a lot of my ideas, it just didn&#8217;t come together. But this time I decided to give you the links so you can make up your own post.</p>

<p>And I&#8217;ll add this: the quintessential R&amp;B instrumental with the classic lineup of Al Jackson, Jr. on drums, Donald &#8220;Duck&#8221; Dunn on bass, Steve Cropper on guitar, and Booker T. Jones on the Hammond B3.</p>

<p><object class="vid" width="500" height="369"><param name="movie" value="http://www.youtube.com/v/U-7QSMyz5rg?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/U-7QSMyz5rg?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="500" height="369" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.leancrew.com/all-this/2012/05/links/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bolt upright</title>
		<link>http://www.leancrew.com/all-this/2012/05/bolt-upright/</link>
		<comments>http://www.leancrew.com/all-this/2012/05/bolt-upright/#comments</comments>
		<pubDate>Sun, 13 May 2012 04:20:34 +0000</pubDate>
		<dc:creator>Dr. Drang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[engineering]]></category>
		<category><![CDATA[fracture]]></category>

		<guid isPermaLink="false">http://www.leancrew.com/all-this/?p=1833</guid>
		<description><![CDATA[Yesterday, my older son mowed the lawn, and I helped him bag the clippings (we&#8217;d gone too long since the last mowing to be able to use the mower&#8217;s mulching feature). Late in the process, I noticed half a bolt lying near the edge of the sidewalk. I poked around in the grass nearby, looking&#8230;]]></description>
			<content:encoded><![CDATA[<p>Yesterday, my older son mowed the lawn, and I helped him bag the clippings (we&#8217;d gone too long since the last mowing to be able to use the mower&#8217;s mulching feature). Late in the process, I noticed half a bolt lying near the edge of the sidewalk. I poked around in the grass nearby, looking for the other half. No luck. I guess the mower blade will find it sooner or later.</p>

<p><a href="http://www.flickr.com/photos/drdrang/7185627280/"><img class="ss" src="http://farm8.staticflickr.com/7094/7185627280_48773383ea_z.jpg" alt="Broken lawn mower bolt" title="Broken lawn mower bolt" /></a></p>

<p>The bolt is one of the four shoulder bolts that connect the bottom of the mower&#8217;s handle to its deck. The handle was a little floppy with only three bolts, but my son managed to finish the lawn anyway.</p>

<p>As you can see, the bolt fractured in the first thread, right next to the unthreaded part of the shank. This is a pretty common place for bolts to fail, as the threads create a stress concentration, and the first thread is typically where that concentration is the greatest.</p>

<p>Flipping the half-bolt up to look at the fracture surface, we see a classic fatigue failure. Fatigue is the gradual accumulation of damage under repeated loads.</p>

<p><a href="http://www.flickr.com/photos/drdrang/7185628256/"><img class="ss" src="http://farm8.staticflickr.com/7097/7185628256_c882235b1d_z.jpg" alt="Bolt fracture surface" title="Bolt fracture surface" /></a></p>

<p>In this photo, the origin of the fracture is at the bottom. It grew upward through at least half the cross-section, leaving behind the concentric arcs known as <em>beach marks</em>. This growth occurred slowly as the load on the bolt was applied and released, applied and released, applied and released. The beach marks represent the edge of the crack front at various points in its growth history.</p>

<p>The upper half of the fracture surface doesn&#8217;t appear to have beach marks, but it&#8217;s possible that there was fatigue crack growth in that zone, too. I&#8217;d have to look at the bolt under a microscope to be sure.</p>

<p>This fracture surface has another interesting feature that&#8217;s common in bolt failures: the radial lines that run inward from the outer edge of the bolt. This comes from the struggle between two tendencies of cracks:</p>

<ul>
<li>They like to run flat in a plane.</li>
<li>They like to run through the weakest part.</li>
</ul>

<p>The weakest part of a bolt is through the root (the bottom of the valley) of the thread. Because the root runs around the outer edge of the bolt in a helix, the crack can&#8217;t be planar <em>and</em> run through the root. It compromises by making little jumps—and occasionally big jumps—at the outside edge. The result is a sort of spiral staircase of cracks running around the helix of the thread root. If you were to shrink down<sup id="fnref:antman"><a href="#fn:antman" rel="footnote">1</a></sup> and start walking counter-clockwise along the edge of the fracture, you&#8217;d find yourself climbing up those stairs. When you&#8217;d gone all the way around, you would have climbed one <a href="http://en.wikipedia.org/wiki/Pitch_(screw)#Lead.2C_pitch.2C_and_starts">thread pitch</a>, and could look down to where you started. You can see the one thread-pitch drop in the top photo.</p>

<p>Because of the particular geometry of the shoulder, I can&#8217;t get replacement bolts at the local hardware store. Luckily, there&#8217;s a <a href="http://www.kippslawnmowersales.com/">lawn mower specialty store</a> one town over that has most replacement parts in stock. After a quick look through the parts manual, I&#8217;ll be giving them a call Monday.</p>

<div class="update">

<p><strong>Update 5/14/12</strong><br />
You know, if I were more like a real blogger, I would&#8217;ve linked to my <a href="http://www.leancrew.com/all-this/2011/04/cracked/">earlier</a> <a href="http://www.leancrew.com/all-this/2011/04/southwest-812/">posts</a> on <a href="http://www.leancrew.com/all-this/2011/09/lets-twist-again/">fatigue</a>. Two of those posts have photos of other items in my house that failed through fatigue: the plastic flushing arm from a toilet, and the oil-tempered steel torsion spring from the garage door.</p>

</div>

<div class="footnotes">
<hr />
<ol>

<li id="fn:antman">
<p>Speaking of which, I&#8217;m a little bummed that <a href="http://en.wikipedia.org/wiki/Henry_Pym">Henry Pym</a>, an original Avenger, isn&#8217;t in the movie. I realize his superpower is kind of funny, but respect should be paid.&#160;<a href="#fnref:antman" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.leancrew.com/all-this/2012/05/bolt-upright/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Large scale structural testing</title>
		<link>http://www.leancrew.com/all-this/2012/05/large-scale-structural-testing/</link>
		<comments>http://www.leancrew.com/all-this/2012/05/large-scale-structural-testing/#comments</comments>
		<pubDate>Sat, 12 May 2012 04:56:01 +0000</pubDate>
		<dc:creator>Dr. Drang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[engineering]]></category>
		<category><![CDATA[mechanics]]></category>

		<guid isPermaLink="false">http://www.leancrew.com/all-this/?p=1832</guid>
		<description><![CDATA[I was kind of busy today, so I just saw this fun Boing Boing piece on the Constructed Facilities Laboratory at NC State. The post, written by Maggie Koerth-Baker, consists largely of a series of short videos from a tour of the lab given by its lab manager, Greg Lucier. The facility seems very nice,&#8230;]]></description>
			<content:encoded><![CDATA[<p>I was kind of busy today, so I just saw <a href="http://boingboing.net/2012/05/11/destroying-stuff-for-science.html#more-143231">this fun Boing Boing piece</a> on the <a href="http://www.ce.ncsu.edu/centers/cfl/index.php">Constructed Facilities Laboratory</a> at NC State. The post, written by Maggie Koerth-Baker, consists largely of a series of short videos from a tour of the lab given by its lab manager, Greg Lucier.</p>

<p>The facility seems very nice, similar in many ways to structural testing labs I&#8217;ve visited at <a href="http://www.atlss.lehigh.edu/">Lehigh</a> and at <a href="http://nsel.cee.illinois.edu/">my own alma mater</a>. Mr. Lucier does a decent job of explaining things, but I can&#8217;t help but think that most of what he said was lost on the members of his tour group. In my experience, even people who have an interest in science and read popular science books don&#8217;t understand the first thing about structural engineering.</p>

<p>Part of this, I&#8217;m sure, is because structural engineering is all around us; it&#8217;s so commonplace that its fundamentals aren&#8217;t taught, even in elementary science classes. Yes, everyone learns about balancing forces, an essential part of structural analysis, but that seems too simple and dull, so the topic quickly changes to kinetics so you can do those wonderfully practical ballistics-in-a-vacuum calculations.</p>

<p>Even the basic vocabulary isn&#8217;t taught. In this part of the tour, poor Greg is explaining how they monitor the response of a large pipe to a bending load, and he points out the <a href="http://www.leancrew.com/all-this/2010/07/bathroom-scales-and-robert-hooke/">gauges</a> bonded to the wall of the pipe for measuring strain. I doubt anyone in the party understands what strain is, so the value of the monitoring is lost on them.</p>

<p><object class="vid" width="500" height="284"><param name="movie" value="http://www.youtube.com/v/abjBs3BcBHk?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/abjBs3BcBHk?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="500" height="284" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>

<p>Elsewhere in the tour, Greg explains their shake table, used to simulate earthquake loading. He gets a question about whether the table can be used to test against any earthquake &#8220;level,&#8221; and he&#8217;s clearly taken aback.</p>

<p><object class="vid" width="500" height="284"><param name="movie" value="http://www.youtube.com/v/gWqqviPl9RE?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/gWqqviPl9RE?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="500" height="284" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>

<p>He reluctantly throws out the word &#8220;magnitude,&#8221; and gets a nod of recognition from the questioner, but you can tell he&#8217;s just disgusted with the idea that his cool shake table, which can reproduce the fine details of any ground acceleration record ever recorded, is somehow controlled by one stupid dial that gets turned to some number between 3 and 10. This fixation on earthquake magnitude—which I blame on those bastard seismologists and their fellow travelers in the so-called mainstream media—prevents people from understanding what&#8217;s really important in determining how a structure reacts to an earthquake.</p>

<p>(My house, by the way, survived a magnitude 9.0 earthquake last year. Yes, <a href="http://en.wikipedia.org/wiki/2011_T%C5%8Dhoku_earthquake">the earthquake was off the coast of Japan</a> and my house is in Naperville. Does that matter?)</p>

<p>The one thing that bothered me about the piece—and this is Maggie&#8217;s fault, not Greg&#8217;s—is the impression it leaves that structural engineers need to test everything before it gets built.</p>

<blockquote>
  <p>Buildings, roads and bridges are all designed with a buffer of safety—basically, engineers round up on the numbers, a lot, and design these things to be far more sturdy than they actually have to be. But to make those decisions, they first have to know the physical limits of the materials they&#8217;re working with. The best way to do that: Take a scaled version of a girder, pillar, or concrete slab and push it past the breaking point.</p>
</blockquote>

<p>In fact, structural engineers are probably less reliant on testing than any other type of engineer. Yes, we need to know the strength of the steel, concrete, or wood used in our structures, and that&#8217;s done through testing of small samples, but once we have those fundamental material properties, we can figure out through rational analysis how to size all the beams and columns of a skyscraper. Most practicing structural engineers never perform the kind of large-scale component and system testing done at the Constructed Facilities Lab.</p>

<p>You wouldn&#8217;t want to buy an iPhone that hadn&#8217;t been rigorously tested before being put on the market. You wouldn&#8217;t drive a type of car that hadn&#8217;t been crash-tested or put through its paces on a test track. But you routinely walk into buildings and drive across bridges that went straight from blueprint to reality. And it&#8217;s perfectly safe to do so.</p>

<p><object class="vid" width="500" height="369"><param name="movie" value="http://www.youtube.com/v/P0Fi1VcbpAI?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/P0Fi1VcbpAI?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="500" height="369" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>

<p>Usually.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leancrew.com/all-this/2012/05/large-scale-structural-testing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flickr as a poor man&#8217;s CDN</title>
		<link>http://www.leancrew.com/all-this/2012/05/flickr-as-a-poor-mans-cdn/</link>
		<comments>http://www.leancrew.com/all-this/2012/05/flickr-as-a-poor-mans-cdn/#comments</comments>
		<pubDate>Thu, 10 May 2012 02:53:27 +0000</pubDate>
		<dc:creator>Dr. Drang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[flickr]]></category>

		<guid isPermaLink="false">http://www.leancrew.com/all-this/?p=1831</guid>
		<description><![CDATA[I&#8217;ve discussed my various Flickr scripts in earlier posts, but I&#8217;ve never laid out in one post the reason I wrote them. This will be that post. All prose, no code—if you want to see the code, it&#8217;s in this GitHub repository. With a few exceptions, all the images—screenshots, photos, and drawings—on this site are&#8230;]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve discussed <a href="http://www.leancrew.com/all-this/2011/07/screenshotupload-utility-now-with-flickr/">my</a> <a href="http://www.leancrew.com/all-this/2011/08/more-flickr-api-stuff/">various</a> <a href="http://www.leancrew.com/all-this/2012/02/snapflickr-update/">Flickr</a> <a href="http://www.leancrew.com/all-this/2012/04/flickr-library-updates/">scripts</a> in earlier posts, but I&#8217;ve never laid out in one post the reason I wrote them. This will be that post. All prose, no code—if you want to see the code, it&#8217;s in <a href="https://github.com/drdrang/flickr-stuff">this GitHub repository</a>.</p>

<p>With a few exceptions, all the images—screenshots, photos, and drawings—on this site are served from my Flickr Pro account. I recognized the advantages of having images on a different server in February of last year, when a post I wrote about <a href="http://www.leancrew.com/all-this/2011/02/iphone-notes-app-comparison/">iPhone text editors</a> got Fireballed. I wasn&#8217;t using a caching plugin at the time, and the post had a dozen screenshots, all of which were served from my web host, which couldn&#8217;t stand the strain. I&#8217;ve been Fireballed a handful of times, but this was the only time a significant number of visitors had to use the cache at Brian Stucki&#8217;s <a href="http://fireballed.org/">fireballed.org</a>.</p>

<p>I solved part of the problem by installing the <a href="http://www.satollo.net/plugins/hyper-cache">Hyper Cache plugin</a> by Stefano Lissa. This makes a static copy of pages when they are first visited and tells WordPress to serve those on subsequent visits instead of rebuilding every page from scratch. It&#8217;s worked quite well. Last December, my post about <a href="http://www.leancrew.com/all-this/2011/12/more-shell-less-egg/">Doug McIlroy and Don Knuth</a> got linked by both Hacker News and Reddit a few days after it was published, and to my knowledge the site never went down, even though the number of pageviews exceeded that of the February Fireballing.<sup id="fnref:chemo"><a href="#fn:chemo" rel="footnote">1</a></sup></p>

<p>Serving images from Flickr was the second stage of load reduction for the web host. As it turned out, there was an additional advantage to using Flickr: because Flickr makes several sizes of every image, I no longer had to do that myself.</p>

<p>Getting the URL of an image hosted on Flickr isn&#8217;t the most straightforward thing in the world. If you want to do it &#8220;by hand,&#8221; you have to run through several steps:</p>

<ol>
<li>Go to the image&#8217;s page.</li>
<li>Choose &#8220;View all sizes&#8221; from the Actions menu.</li>
<li>Click on the size you want.</li>
<li>Right click on the Download link to copy the image URL.</li>
<li>Paste the URL into your post.</li>
</ol>

<p>To speed this up, I wrote some Python code and a set of <a href="http://itunes.apple.com/us/app/textexpander-for-mac/id405274824?mt=12&amp;partnerId=30&amp;siteID=L4JhWyGwYTM">TextExpander</a> snippets that allow me to reduce that to two steps:</p>

<ol>
<li>Go to the image&#8217;s page.</li>
<li>Type the appropriate abbreviation for the URL of the image size I want (e.g., <code>;640</code> for a Medium 640).</li>
</ol>

<p>Regardless of how I get the image onto my page, the <a href="http://www.flickr.com/guidelines.gne">Flickr Community Guidelines</a> require a link back to the Flickr image page:</p>

<blockquote>
  <p>[P]ages on other web sites that display content hosted on flickr.com must provide a link from each photo or video back to its page on Flickr.</p>
</blockquote>

<p>I always use the image itself as the link. Getting the URL of the image&#8217;s page is easy—I just use my <a href="http://www.leancrew.com/all-this/2010/10/textexpander-snippet-repository/"><code>;furl</code> TextExpander snippet</a>, which inserts the URL of the frontmost Safari tab. As it happens, this is also easier when I use my two-step process because I never leave the Flickr image page.</p>

<p>Since I use a lot of screenshots in my posts, I wanted a fast way to upload them to Flickr. The <a href="https://github.com/drdrang/flickr-stuff">repository</a> has a script called <code>snapflickr</code> which:</p>

<ol>
<li>Takes a snapshot of either a window or a rectangle of the screen (just like the built-in ⇧⌘4 action).</li>
<li>Asks me to name it.</li>
<li>Uploads the image to Flickr.</li>
<li>Opens a new tab in Safari (or whatever the default browser is) to the image&#8217;s Flickr page.</li>
<li>Puts the appropriate <code>&lt;img&gt;</code> link on the clipboard ready for pasting into a post.<sup id="fnref:markdown"><a href="#fn:markdown" rel="footnote">2</a></sup></li>
</ol>

<p>I know there are commercial programs that assist with taking screenshots and uploading, but nothing can compare with a script written to match your workflow precisely. Gabe at Macdrifter does <a href="http://www.macdrifter.com/2012/05/automated-ftp-from-dropbox-with-hazel/">something similar</a> with Hazel and Python.</p>

<p>One thing did change when I started using Flickr to host screenshots: I had to change my screenshot format from PNG to JPEG. Flickr accepts PNGs, but it saves the resized images as JPEGs, and any transparent areas in the original PNG become black in the resized JPEGs. Since many of my screenshots are of windows with the semi-transparent shadow, the resized versions on Flickr look like shit. With JPEG screenshots, the window shadow backgrounds are white, which is just what I want.</p>

<p>So there you have it. I wanted to use Flickr as a sort of content distribution network for images, so I wrote a few scripts to make it easy to do so. My web host is relieved of some burden, and I can put together a post as quickly as I could before.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:chemo">
<p>That was a weird day. I was with my wife at the local cancer center for her first day of chemo. She had her iPad and I had my MacBook Air, and we were playing Words With Friends to keep our minds off the poisons that were flowing into her arm. At some point, while the nurse was changing from one poison to another, I checked ANIAT and noticed there were a bunch of new comments. Where the hell are these people coming from? Then I looked at Google Analytics and saw a huge spike. On another day, I might&#8217;ve thought that was important.&#160;<a href="#fnref:chemo" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:markdown">
<p>You may be wondering why I&#8217;m using HTML to define an image link when I write my posts in Markdown. Two reasons:</p>

<ol>
<li>I&#8217;ve never liked the <code>![]()</code> notation Markdown uses for image links. It&#8217;s barely shorter than full HTML and less obvious.</li>
<li>I like to use a particular CSS class for images in my posts so they get centered. Markdown doesn&#8217;t allow that.</li>
</ol>

<p>Since Markdown does allow embedded HTML, that&#8217;s what I use for images.&#160;<a href="#fnref:markdown" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.leancrew.com/all-this/2012/05/flickr-as-a-poor-mans-cdn/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>As easy as falling off…</title>
		<link>http://www.leancrew.com/all-this/2012/05/as-easy-as-falling-off/</link>
		<comments>http://www.leancrew.com/all-this/2012/05/as-easy-as-falling-off/#comments</comments>
		<pubDate>Tue, 08 May 2012 04:30:00 +0000</pubDate>
		<dc:creator>Dr. Drang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[mathjax]]></category>

		<guid isPermaLink="false">http://www.leancrew.com/all-this/?p=1830</guid>
		<description><![CDATA[The other day I was thinking about how to present a set of data, and I started fiddling around with histograms. Histograms are easy to make, but if they&#8217;re going to be representative of the data, the size of the bins has to be reasonable. Bins that are to narrow make the data set look&#8230;]]></description>
			<content:encoded><![CDATA[<p>The other day I was thinking about how to present a set of data, and I started fiddling around with histograms. Histograms are easy to make, but if they&#8217;re going to be representative of the data, the size of the bins has to be reasonable. Bins that are to narrow make the data set look less regular than it is; bins that are too wide throw away information and are biased away from the underlying density function at the edges of the bins.</p>

<p>There&#8217;s a simple rule, called <em>Sturges&#8217;s rule</em>, for choosing a reasonable bin width. Despite its simplicity, I can never remember it. Fortunately, I <em>can</em> remember which of my books has it in an easily found location. It&#8217;s Elmer Lewis&#8217;s <a href="http://books.google.com/books/about/Introduction_to_reliability_engineering.html?id=429RAAAAMAAJ"><em>Introduction to Reliability Engineering</em></a>, which gives the width as</p>

<span class="MathJax_Preview">[w = \frac{x_{max} - x_{min}}{1 + 3.3\; \log_{10} n}]</span><script type="math/tex; mode=display">w = \frac{x_{max} - x_{min}}{1 + 3.3\; \log_{10} n}</script>

<p>where <span class="MathJax_Preview">[n]</span><script type="math/tex">n</script> is the number of samples, <span class="MathJax_Preview">[x_{min}]</span><script type="math/tex">x_{min}</script> is the smallest sample, and <span class="MathJax_Preview">[x_{max}]</span><script type="math/tex">x_{max}</script> is the largest sample.</p>

<p>I&#8217;ve used this formula unquestioningly dozens of times, but for some reason this time I wanted to see how it was derived. OK, not &#8220;some reason&#8221;; I was looking for an opportunity to procrastinate. So I Googled &#8220;<a href="http://www.google.com/search?q=sturges+histogram&amp;ie=UTF-8&amp;oe=UTF-8">Sturges histogram</a>&#8221; and started clicking likely links.</p>

<p>The first thing I noticed was that none of the sources gave the formula the same way Elmer did. They gave it as</p>

<span class="MathJax_Preview">[w = \frac{x_{max} - x_{min}}{1 + \log_2 n}]</span><script type="math/tex; mode=display">w = \frac{x_{max} - x_{min}}{1 + \log_2 n}</script>

<p>which looks a lot more like something derived from first principles. I&#8217;d always looked at the <span class="MathJax_Preview">[\log_{10}]</span><script type="math/tex">\log_{10}</script> and the 3.3 in Elmer&#8217;s version of the formula and assumed that it was some empirically derived best fit to a series of numerical experiments. But a nice, simple <span class="MathJax_Preview">[\log_2]</span><script type="math/tex">\log_2</script> could only come from a theoretical derivation. Elmer had obviously converted the <span class="MathJax_Preview">[\log_2 n]</span><script type="math/tex">\log_2 n</script> to <span class="MathJax_Preview">[3.3\;\log_{10} n]</span><script type="math/tex">3.3\;\log_{10} n</script> to make the formula easier to use for engineers, who would feel more comfortable with base-10 logs and probably wouldn&#8217;t have a base-2 log function on their calculators.</p>

<p>Here&#8217;s the embarrassing part: as I saw this, I realized that I&#8217;d forgotten how to convert logarithms from one base to another. Oh, I knew that the conversion factor to go from base-<span class="MathJax_Preview">[a]</span><script type="math/tex">a</script> to base-<span class="MathJax_Preview">[b]</span><script type="math/tex">b</script> was either <span class="MathJax_Preview">[\log_a b]</span><script type="math/tex">\log_a b</script> or <span class="MathJax_Preview">[\log_b a]</span><script type="math/tex">\log_b a</script> (or maybe the reciprocal of one of those), but I didn&#8217;t feel confident I knew which. It drove me crazy.</p>

<p>So I sat down with a pencil and paper and figured it out, like I had to do in junior high. I started with my best guess</p>

<span class="MathJax_Preview">[\log_a n \stackrel{?}{=} \log_a b \; \log_b n]</span><script type="math/tex; mode=display">\log_a n \stackrel{?}{=} \log_a b \; \log_b n</script>

<p>and raised <span class="MathJax_Preview">[a]</span><script type="math/tex">a</script> to both sides</p>

<span class="MathJax_Preview">[a^{\log_a n} \stackrel{?}{=} a^{\log_a b \; \log_b n}]</span><script type="math/tex; mode=display">a^{\log_a n} \stackrel{?}{=} a^{\log_a b \; \log_b n}</script>

<p>The left side was easy to simplify with the definition of a logarithm. The right needed to be rearranged using the rule for product exponents.</p>

<span class="MathJax_Preview">[n \stackrel{?}{=} \left( a^{\log_a b} \right)^{\log_b n}]</span><script type="math/tex; mode=display">n \stackrel{?}{=} \left( a^{\log_a b} \right)^{\log_b n}</script>

<p>Now apply the logarithm definition to the right side once,</p>

<span class="MathJax_Preview">[n \stackrel{?}{=} b^{\log_b n}]</span><script type="math/tex; mode=display">n \stackrel{?}{=} b^{\log_b n}</script>

<p>and then again to give the equality I was hoping for,</p>

<span class="MathJax_Preview">[n = n]</span><script type="math/tex; mode=display">n = n</script>

<p>which meant that my initial guess was correct.</p>

<p>Even though this was a proof I first learned about 40 years ago, I was happy to see that I could still do it without cheating, without looking it up somewhere. The Van Camp&#8217;s people were right: <a href="http://www.youtube.com/watch?v=sjzinJ4QeHo">simple pleasures are the best</a>.</p>

<hr />

<p>I need to add two notes before closing this post:</p>

<ol>
<li>This is my first post since <a href="http://www.mathjax.org/2012/05/07/news/upcoming-changes-to-the-cdn/">switching to MathJax&#8217;s new CDN</a>. The changeover seems to have gone smoothly.</li>
<li>I learned how to make the <span class="MathJax_Preview">[\stackrel{?}{=}]</span><script type="math/tex">\stackrel{?}{=}</script> symbol from <a href="http://stackoverflow.com/questions/2331492/how-do-i-put-a-question-mark-above-leq">this Stack Overflow page</a>. The LaTeX code is <code>\stackrel{?}{=}</code>.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.leancrew.com/all-this/2012/05/as-easy-as-falling-off/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The best Markdown editor is any editor</title>
		<link>http://www.leancrew.com/all-this/2012/05/the-best-markdown-editor-is-any-editor/</link>
		<comments>http://www.leancrew.com/all-this/2012/05/the-best-markdown-editor-is-any-editor/#comments</comments>
		<pubDate>Mon, 07 May 2012 04:05:57 +0000</pubDate>
		<dc:creator>Dr. Drang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[markdown]]></category>
		<category><![CDATA[text editing]]></category>

		<guid isPermaLink="false">http://www.leancrew.com/all-this/?p=1829</guid>
		<description><![CDATA[I&#8217;ve long known and accepted that regular people view me as something of an oddball, but it&#8217;s still unnerving when I discover another aspect in which I&#8217;m out of step even with the nerds who should be my off-center kith and kin. I can reconcile my dislike of Star Wars and my complete indifference to&#8230;]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve long known and accepted that regular people view me as something of an oddball, but it&#8217;s still unnerving when I discover another aspect in which I&#8217;m out of step even with the nerds who should be my off-center kith and kin. I can reconcile <a href="http://www.leancrew.com/all-this/2011/04/lester-del-rey-and-star-wars/">my dislike of <em>Star Wars</em></a> and my complete indifference to videogames to a generational difference—I was just a few years too old when they came along. But now I see the favorable reactions to <a href="http://brettterpstra.com/my-ultimate-markdown-editor-wishlist/">Brett Terpstra&#8217;s Markdown editor wish list</a>, and I wonder: Am I an outcast even among Markdown users?</p>

<p>It&#8217;s not that I have no interest in making Markdown easier to write. I have a handful of Markdown-specific TextMate commands that I&#8217;d hate to be without. But much of Brett&#8217;s list just seems unnecessary, and a couple of items strike me as distinctly wrong. I&#8217;m going to go through the list in the same order Brett did, and I&#8217;m not going to recap his descriptions, so if you haven&#8217;t read <a href="http://brettterpstra.com/my-ultimate-markdown-editor-wishlist/">his post</a>, this&#8217;ll mean nothing to you.</p>

<ul>
<li>The list starts out well. ⌘B and ⌘I for bold (strong) and italics (em)? Certainly. Intelligent indentation? Wouldn&#8217;t have it any other way.</li>
<li>I can&#8217;t say I&#8217;m against list continuation, but I don&#8217;t feel unduly burdened if I have to type asterisk-space or numeral-period-space. TextMate&#8217;s current Markdown bundle does much of what Brett wants in this regard<sup id="fnref:tm-list"><a href="#fn:tm-list" rel="footnote">1</a></sup>, and I use it when writing on my MacBook Air. But when I&#8217;m writing on my old iMac, which apparently still has an old version of the Markdown bundle, there&#8217;s no list continuation, and my writing isn&#8217;t affected in the least.</li>
<li>The auto-pairing and wrapping items mean nothing to me. TextMate has had auto-pairing for years, but I keep it turned off. Every time I give it a try—everyone seems to love it; let&#8217;s see how it works—it just gets in my way.</li>
<li>Link pasting is one of those distinctly wrong things. Pasting means something, and it should always do the same thing. Having its behavior depend on the format of the clipboard contents is a recipe for confusion and anger.</li>
<li>Tabbing to indent a selected block? OK, I guess, but I prefer a keyboard shortcut to a regular key. I like my regular keys to insert the same thing every time.<sup id="fnref:regular"><a href="#fn:regular" rel="footnote">2</a></sup></li>
<li>I have no interest in shortcuts for moving lines up and down. It doesn&#8217;t happen often enough that I&#8217;d be able to remember the shortcut, and the standard editing commands are efficient enough for me.</li>
<li>Even though I&#8217;m not a big fan of auto-completion in general, auto-completion of reference titles sounds like a great idea.</li>
<li>Brett&#8217;s desired shortcut for inserting footnotes is similar to a TextMate command I&#8217;ve stopped using. It turns out that Markdown<sup id="fnref:footnotes"><a href="#fn:footnotes" rel="footnote">3</a></sup> can be tetchy about where you put the footnote text, especially when you&#8217;re in a list, so it&#8217;s generally better to place your footnote text &#8220;by hand.&#8221;</li>
<li>I&#8217;m unenthused by the proposed shortcut for inserting reference links because I think <a href="http://www.leancrew.com/all-this/2006/03/markdown-links-in-textmate-the-final-frontier/">my system for reference links</a> (which puts them at the end of the document where God intended) is better.</li>
<li>I doubt that I&#8217;d use the headline level conversion shortcut very often, but it seems pretty handy.</li>
<li>Switching between ordered and unordered lists sounds like a useful shortcut, but I don&#8217;t see why anyone would need to convert a series of lines into a list. If you&#8217;re adding lines one after the other, you would know right from the beginning that you&#8217;re making a list.</li>
<li>I can see how the blockquote level shortcut would be a real timesaver to people like John Gruber who write posts that are mostly quotes, but for those of us writing original material, inserting the occasional greater-than sign isn&#8217;t a big deal.</li>
<li>Creating a list of references from URLs on the clipboard? Great idea. Same with converting inline links to reference links, even though I have no use for it.</li>
<li>Using Shift-Return or Command-Return to add two spaces before the newline (to get a line break) strikes me as a terrible idea. The Markdown way of getting a line break is one of my least favorite features, because it uses invisible characters to affect the formatting.<sup id="fnref:invisible"><a href="#fn:invisible" rel="footnote">4</a></sup> Having invisible characters inserted automatically compounds the problem. And really, doesn&#8217;t it take longer to remember to type Shift-Return than it does to type Space-Space-Return?</li>
<li>I understand the desire to change the behavior of ⌘← and ⌘→ to stop at the last visible character, but standard editing shortcuts shouldn&#8217;t be messed with.</li>
</ul>

<p>I guess the real problem with Brett&#8217;s list and me is that I disagree with the entire notion of a Markdown editor. Markdown is just plain text—any text editor should do just fine. By design, very few of Markdown&#8217;s formatting &#8220;commands&#8221; involve more than a few normal keystrokes—this isn&#8217;t HTML or LaTeX. Trying to remember a dozen or more hotkey combinations to do things that are both relatively rare and easily accomplished with a small amount of normal typing seems like the wrong thing to be using your brain for. And, <a href="http://www.asktog.com/TOI/toi06KeyboardVMouse1.html">with this as my basis</a>, I don&#8217;t believe it&#8217;s any more efficient than just typing.</p>

<p>The recent popularity of Markdown editors suggests I&#8217;m on the wrong side of history here. Oh, well. I&#8217;m getting used to it.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:tm-list">
<p>It also screws up lists sometimes when I try to edit them, but it&#8217;s not fair to stain Brett&#8217;s wish with the bugs in a specific implementation.&#160;<a href="#fnref:tm-list" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:regular">
<p>Wait, didn&#8217;t I just say I like intelligent indentation? And don&#8217;t I use soft tabs? Yes and yes. <a href="http://www.brainyquote.com/quotes/quotes/w/waltwhitma132584.html">I am large, I contain multitudes.</a>&#160;<a href="#fnref:regular" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:footnotes">
<p>Actually, this applies only &#8220;enhanced&#8221; processors like MultiMarkdown and PHP Markdown Extra, as standard Markdown doesn&#8217;t have footnotes.&#160;<a href="#fnref:footnotes" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:invisible">
<p>No, I don&#8217;t have a better idea.&#160;<a href="#fnref:invisible" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.leancrew.com/all-this/2012/05/the-best-markdown-editor-is-any-editor/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Afghanistan, April 2012</title>
		<link>http://www.leancrew.com/all-this/2012/05/afghanistan-april-2012/</link>
		<comments>http://www.leancrew.com/all-this/2012/05/afghanistan-april-2012/#comments</comments>
		<pubDate>Sat, 05 May 2012 23:32:58 +0000</pubDate>
		<dc:creator>Dr. Drang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[afghanistan]]></category>
		<category><![CDATA[politics]]></category>
		<category><![CDATA[war]]></category>

		<guid isPermaLink="false">http://www.leancrew.com/all-this/?p=1827</guid>
		<description><![CDATA[The idea that the war in Afghanistan is winding down is belied by April&#8217;s US and coalition military death figures. The latest dots on this absurdly long graph—we&#8217;re heading toward 11 years—are right in the middle of the range we&#8217;ve seen since the spring of ’09. It&#8217;s been a year since bin Laden was found&#8230;]]></description>
			<content:encoded><![CDATA[<p>The idea that the war in Afghanistan is winding down is belied by April&#8217;s US and coalition military death figures.</p>

<p><a href="http://www.leancrew.com/all-this/images2012/ac-2012-04.png"><img class="ss" src="http://www.leancrew.com/all-this/images2012/ac-2012-04-t.png" alt="Afghanistan, April 2012" title="Afghanistan, April 2012" /></a></p>

<p>The latest dots on this absurdly long graph—we&#8217;re heading toward <em>11 years</em>—are right in the middle of the range we&#8217;ve seen since the spring of ’09. It&#8217;s been a year since bin Laden was found and killed and ages since it was clear that we&#8217;re not going to establish any sort of Western-style democracy there. What now is the value in staying?</p>

<p>We know the cost. Barring a miracle, coalition deaths will pass the 3,000 mark this month, and US deaths will pass 2,000 this summer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leancrew.com/all-this/2012/05/afghanistan-april-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iCloud and calendar alarms</title>
		<link>http://www.leancrew.com/all-this/2012/05/icloud-and-calendar-alarms/</link>
		<comments>http://www.leancrew.com/all-this/2012/05/icloud-and-calendar-alarms/#comments</comments>
		<pubDate>Fri, 04 May 2012 03:24:41 +0000</pubDate>
		<dc:creator>Dr. Drang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[alarms]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[ical]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://www.leancrew.com/all-this/?p=1826</guid>
		<description><![CDATA[When I&#8217;ve complained about iCloud in the past, it was because iCloud—or one of the apps that sync via iCloud—had failed to do what it was supposed to. In one case, I ended up with duplicate calendar entries; in another, some Address Book contacts refused to appear on my iPhone. Today I&#8217;m going to complain&#8230;]]></description>
			<content:encoded><![CDATA[<p>When I&#8217;ve complained about iCloud in the past, it was because iCloud—or one of the apps that sync via iCloud—had failed to do what it was supposed to. In one case, I ended up with <a href="http://www.leancrew.com/all-this/2011/10/eliminating-doubled-iphone-calendar-entries/">duplicate calendar entries</a>; in another, some Address Book contacts <a href="http://www.leancrew.com/all-this/2012/04/address-book-and-icloud-problems/">refused to appear on my iPhone</a>. Today I&#8217;m going to complain about iCloud working exactly as Apple intends. More perversely, I&#8217;m going to complain about a behavior that I think is correct.</p>

<div class="update">

<p><strong>Update 5/4/12</strong><br />
The behavior described in this post was due to a couple of choices in the Settings for Mail, Contacts, and Calendars. Joe Saponare&#8217;s comment explains the problem well.</p>

<p>I&#8217;m still not sure whether I made the choice to have iCloud sync manually (and have forgotten about it) or whether that was the default when I updated to iOS 5. I&#8217;ve changed my setting from Manual to Push and will be monitoring battery life to see if there&#8217;s a notable reduction.</p>

</div>

<p>Try this two-part experiment: First, make a calendar entry on your Mac<sup id="fnref:ical"><a href="#fn:ical" rel="footnote">1</a></sup> for later today. Now pull out your iPhone and open the Calendar app.<sup id="fnref:app"><a href="#fn:app" rel="footnote">2</a></sup> Move to today&#8217;s date if you&#8217;re not already there. The event you just added won&#8217;t be there at first, but soon you&#8217;ll see the little gear icon spinning at the top and a few seconds later the new event will appear. Great.</p>

<p><a href="http://www.flickr.com/photos/drdrang/6994661412/"><img class="ss" src="http://farm8.staticflickr.com/7088/6994661412_2076a4b175_z.jpg" alt="Calendar syncing" title="Calendar syncing" /></a></p>

<p>Now for the second part. Make a new calendar entry on your Mac for five minutes from now and give it an alarm to sound at the time of the event (0 minutes before). Now go to your iPhone<sup id="fnref:ipad"><a href="#fn:ipad" rel="footnote">3</a></sup> and check your Twitter feed, play a round of <a href="http://itunes.apple.com/us/app/spelltower/id476500832?mt=8&amp;partnerId=30&amp;siteID=L4JhWyGwYTM">SpellTower</a>—do anything <em>but</em> open the Calendar app. Does the alarm sound when the five minutes have passed? No.</p>

<p>This is because calendar events are synced only when the Calendar app is open. There&#8217;s no automatic syncing every so many minutes. This is a deliberate choice by Apple and is, I&#8217;m sure, intended to save battery life. Changes to your calendar are relatively infrequent, and turning on the antennas periodically to look for new entries that are almost never there doesn&#8217;t make a lot of sense. Almost every time you want to know about a new entry, you&#8217;ll have the Calendar app open, and since that&#8217;s when the syncing happens, everything works out just fine.</p>

<p>Except when the new event has an alarm, and you don&#8217;t open Calendar sometime before the alarm is set to sound. For that one particular case, Apple&#8217;s decision on when to sync will fail you; you won&#8217;t get an alarm that you were supposed to.</p>

<p>I first noticed this—bug? anomaly? I don&#8217;t know what to call it—on Monday morning when I arrived at work and saw an iCal alert window on my screen for an <a href="http://www.leancrew.com/all-this/2012/04/heavens-above-repository/">Iridium flare</a> that&#8217;d happened Sunday night. Why didn&#8217;t I get an alarm on my phone? I wondered. I pulled out the phone, launched the Calendar app, and moved to Sunday. No Iridium flare event. But then the syncing gear spun, the Iridium flare event popped into place, and light dawned. The script that puts the dates and times for a week&#8217;s worth of  Iridium flare events into my calendar runs every Sunday morning. I hadn&#8217;t opened the Calendar app on my phone that Sunday, so there was no syncing and therefore no alarm Sunday night.</p>

<p>Luckily, this wasn&#8217;t an important alarm, and now that I know how syncing works, I&#8217;ll be sure to open the Calendar app on my phone every time I add an alarmed event on my computer.</p>

<p>Am I angry at Apple for choosing battery life over periodic syncing? No, I think it made the right choice, but it&#8217;s a choice that can bite you if you don&#8217;t know about it. I&#8217;ve seen plenty of complaints about iCloud over the past several months, but never about this particular behavior. If you didn&#8217;t know about it either, now you do.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:ical">
<p>It doesn&#8217;t matter which calendar app you use, as long as it works with the iCal database and you&#8217;re connected to the internet for syncing with iCloud.&#160;<a href="#fnref:ical" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:app">
<p>Again, it doesn&#8217;t matter which calendar app you use as long as it uses the built-in Calendar&#8217;s data.&#160;<a href="#fnref:app" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:ipad">
<p>I assume things work the same way on an iPad, but I don&#8217;t have an iPad and can&#8217;t test it.&#160;<a href="#fnref:ipad" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.leancrew.com/all-this/2012/05/icloud-and-calendar-alarms/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Where modules go to die</title>
		<link>http://www.leancrew.com/all-this/2012/04/where-modules-go-to-die/</link>
		<comments>http://www.leancrew.com/all-this/2012/04/where-modules-go-to-die/#comments</comments>
		<pubDate>Tue, 01 May 2012 03:20:25 +0000</pubDate>
		<dc:creator>Dr. Drang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.leancrew.com/all-this/?p=1825</guid>
		<description><![CDATA[When I wrote my &#8220;Python doesn&#8217;t play well with others&#8221; post a couple of weeks ago, I didn&#8217;t know that I was treading on ground already well-traveled by Kenneth Reitz. I should have known that the programmer behind the envoy library—which I mentioned in that post and which I&#8217;ve adopted as my go-to library for&#8230;]]></description>
			<content:encoded><![CDATA[<p>When I wrote my &#8220;<a href="http://www.leancrew.com/all-this/2012/04/python-doesnt-play-nicely-with-others/">Python doesn&#8217;t play well with others</a>&#8221; post a couple of weeks ago, I didn&#8217;t know that I was treading on ground already well-traveled by <a href="http://www.kennethreitz.com/">Kenneth Reitz</a>. I should have known that the programmer behind the <a href="https://github.com/kennethreitz/envoy">envoy library</a>—which I mentioned in that post and which I&#8217;ve adopted as my go-to library for running external processes—would have an overarching interest in making Python libraries simpler and more obvious for common uses.</p>

<p>In addition to envoy, Reitz is the lead developer of</p>

<ul>
<li><a href="https://github.com/kennethreitz/requests">requests</a>, a library that simplifies HTTP communication;</li>
<li><a href="https://github.com/kennethreitz/clint">clint</a>, a library for building command line tools; and</li>
<li><a href="https://github.com/kennethreitz/tablib">tablib</a>, a library for handling tabular data that can generate output in many formats.</li>
</ul>

<p>He&#8217;s prepared <a href="http://python-for-humans.heroku.com/#1">a set of slides</a> for a talk entitled &#8220;Python for Humans,&#8221; a shortened version of which he delivered at a Django conference earlier this month.</p>

<p><object class="vid" width="500" height="284"><param name="movie" value="http://www.youtube.com/v/Q1pe6lHZeNs?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Q1pe6lHZeNs?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="500" height="284" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>

<p>In this abbreviated talk, he spent most of his time on his request library and the problems with urllib2 that he was trying to solve. Reitz&#8217;s position is that several of the modules in the standard library violate one or more of the <a href="http://www.python.org/dev/peps/pep-0020/">Zen of Python</a> rules, especially</p>

<blockquote>
  <p>Beautiful is better than ugly.</p>
  
  <p>If the implementation is hard to explain, it&#8217;s a bad idea.</p>
</blockquote>

<p>and</p>

<blockquote>
  <p>There should be one—and preferably only one—obvious way to do it.</p>
</blockquote>

<p>In the talk, Reitz describes several possibilities a new Python programmer would have to sift through if she were trying to write a program that communicated via HTTP. We saw a similar thing in <a href="http://www.leancrew.com/all-this/2012/04/python-doesnt-play-nicely-with-others/">my subprocess post</a>: the standard library contains at least three ways to call an external program from within Python.</p>

<p>I suspect that some of the standard libraries are convoluted because there&#8217;s a sense that they have to cover all cases. The implementation then gets weighted down by the need to handle every edge condition imaginable, and the simple, common uses are buried under layers of objects and method parameter lists.</p>

<p>Reader Carl said, in <a href="http://www.leancrew.com/all-this/2012/04/ftp-v-ftplib/">a comment</a> to another of my Python library complaints</p>

<blockquote>
  <p>The problem with the “batteries included” philosophy of Python is that a lot of batteries got written back in the Python 2.0 days and haven’t been updated since, but because they already exist, no third party libraries catch on to serve the same niche.</p>
</blockquote>

<p>This is exactly right. The standard libraries constitute one of Python&#8217;s great features, but they tend to suck up all the oxygen. Programmers are reluctant to write libraries that duplicate their functions, so poor libraries in the standard set persist. Only a few people, like Reitz, are willing to write modules that compete with the standards.</p>

<p>Near the end of his talk, Reitz says, &#8220;The standard library is where modules go to die.&#8221; An overstatement, certainly, but with more than a germ of truth. Once a library is enshrined in the standard set, it can&#8217;t change radically because too many programs rely on it—and its bugs, idiosyncrasies, and complications—remaining stable.</p>

<p>Several Python programmers on Hacker News thought my complaints about the subprocess module were unfounded. I was glad to see that core developer <a href="http://www.boredomandlaziness.org/">Nick Coghlan</a> <a href="http://www.leancrew.com/all-this/2012/04/python-doesnt-play-nicely-with-others/#comment-20129">agreed with me</a>, as did Reitz:</p>

<div class="bbpBox" id="t192391385737994240"><blockquote><span class="twContent">An awesome article on the frustrations of using the subprocess module: <a href="http://www.leancrew.com/all-this/2012/04/python-doesnt-play-nicely-with-others/">leancrew.com/all-this/2012/…</a></span><span class="twMeta"><br /><span class="twDecoration">&nbsp;&nbsp;&mdash; </span><span class="twRealName">Kenneth Reitz</span><span class="twDecoration"> (</span><a href="http://twitter.com/kennethreitz"><span class="twScreenName">@kennethreitz</span></a><span class="twDecoration">) </span><a href="https://twitter.com/#!/kennethreitz/status/192391385737994240"><span class="twTimeStamp">Tue Apr 17 2012</span></a><span class="twDecoration"></span></span></blockquote></div>

<p>The &#8220;awesome&#8221; is hyperbole, but it&#8217;s nice to see people with real influence in the Python community recognizing the value of making the language and its libraries accessible to lesser programmers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leancrew.com/all-this/2012/04/where-modules-go-to-die/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

