<?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>I Believe Two Things &#187; Programming</title>
	<atom:link href="http://blog.benjaminfenster.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.benjaminfenster.com</link>
	<description>A Blog of Musings and Mockery</description>
	<lastBuildDate>Sat, 04 Feb 2012 13:58:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Drivers, Ms. Daisy</title>
		<link>http://blog.benjaminfenster.com/2012/01/drivers-ms-daisy/</link>
		<comments>http://blog.benjaminfenster.com/2012/01/drivers-ms-daisy/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 11:39:47 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Anecdotes]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.benjaminfenster.com/?p=2238</guid>
		<description><![CDATA[A relative&#8217;s Dell XPS 8000 recently suffered a hard drive failure and had to be restored from backup onto a new drive. Naturally, it could no longer connect to the Internet. Problem 1: The machine&#8217;s BIOS no longer recognized any USB keyboard that Dell didn&#8217;t create, and so wouldn&#8217;t boot with my keyboard in order [...]]]></description>
			<content:encoded><![CDATA[<p>A relative&#8217;s Dell XPS 8000 recently suffered a hard drive failure and had to be restored from backup onto a new drive. Naturally, it could no longer connect to the Internet.</p>
<p><em>Problem 1</em>: The machine&#8217;s BIOS no longer recognized any USB keyboard that Dell didn&#8217;t create, and so wouldn&#8217;t boot with my keyboard in order to fix the problem. I had to borrow a Dell keyboard.</p>
<p><em>Problem 2</em>: Windows did not have valid drivers for either the wireless or wired network cards. Dell distributes the drivers via its website, but without already having the drivers it&#8217;s impossible to connect to the Internet. I had to download them from my iMac, burn a DVD, and load them from DVD on the PC.</p>
<p><em>Problem 3</em>: When given the &#8220;Service Tag&#8221; for this machine, supposedly identifying the specific machine so Dell can provide the correct drivers, Dell provides 64 bit drivers which are completely incompatible with the 32 bit processor. This one was a doozy. I had to ask Google to find every possible driver for any model Broadcom NIC and then try them all until one worked.</p>
<p>Just for a little comparison, my own iMac suffered a hard drive failure last year. Apple installed a new drive, I restored from Time Machine, and it was like nothing had ever happened.</p>
<p>I don&#8217;t mean to insight a religious Mac vs. PC debate, and in fact Apple does plenty of stuff I dislike, but that much effort to connect to the Internet (via a wired connection, no less) is just ridiculous.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.benjaminfenster.com/2012/01/drivers-ms-daisy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>This is a UNIX System! I Know This!</title>
		<link>http://blog.benjaminfenster.com/2011/04/this-is-a-unix-system-i-know-this/</link>
		<comments>http://blog.benjaminfenster.com/2011/04/this-is-a-unix-system-i-know-this/#comments</comments>
		<pubDate>Sun, 10 Apr 2011 20:39:50 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Movies]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.benjaminfenster.com/?p=1965</guid>
		<description><![CDATA[Movies are infamously terrible at depicting computers with even a modicum of accuracy. Even UNIX gurus raised an eyebrow in confusion when Lex announced in Jurassic Park, &#8220;It&#8217;s a UNIX system! I know this!&#8221; (In fairness, she was at least looking at a real application, but not one readily recognizable as &#8220;UNIX&#8221;.) In delightful contrast [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_1968" class="wp-caption alignleft" style="width: 160px"><a href="http://blog.benjaminfenster.com/wp-content/uploads/2011/04/jurassic-park-unix.jpg"><img class="size-thumbnail wp-image-1968 " title="It's a UNIX System" src="http://blog.benjaminfenster.com/wp-content/uploads/2011/04/jurassic-park-unix-150x150.jpg" alt="It's a UNIX System" width="150" height="150" /></a><p class="wp-caption-text">It&#39;s a UNIX System</p></div>
<p>Movies are infamously terrible at depicting computers with even a modicum of accuracy. Even UNIX gurus raised an eyebrow in confusion when Lex announced in <em>Jurassic Park</em>, &#8220;It&#8217;s a UNIX system! I know this!&#8221; (In fairness, she was at least looking at a real application, but not one readily recognizable as &#8220;UNIX&#8221;.)</p>
<p>In delightful contrast to the stereotypical Hollywood computer experience, Joshua Nimoy <a href="http://jtnimoy.net/workviewer.php?q=178">describes creating the special effects for Tron Legacy</a>. I particularly enjoy the use of emacs.</p>
<p>(via <a href="http://kottke.org/11/04/tron-legacys-special-effects">kottke</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.benjaminfenster.com/2011/04/this-is-a-unix-system-i-know-this/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Open Two Instances of Mac OS X Applications</title>
		<link>http://blog.benjaminfenster.com/2011/02/open-two-instances-of-mac-os-x-applications/</link>
		<comments>http://blog.benjaminfenster.com/2011/02/open-two-instances-of-mac-os-x-applications/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 14:12:13 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.benjaminfenster.com/?p=1924</guid>
		<description><![CDATA[Whitson Gordon at Lifehacker just revealed the most exciting thing I&#8217;ve ever learned about Mac OS X: the secret to opening two instances of the same application simultaneously. Unlike Windows, Mac OS X normally only opens each application one time. Then as you try to open new files the application just creates a new window for [...]]]></description>
			<content:encoded><![CDATA[<p>Whitson Gordon at Lifehacker just revealed the most exciting thing I&#8217;ve ever learned about Mac OS X: the secret to <a href="http://lifehacker.com/#!5766390/how-to-open-two-instances-of-an-application-in-os-x">opening two instances of the same application simultaneously</a>.</p>
<p>Unlike Windows, Mac OS X normally only opens each application one time. Then as you try to open new files the application just creates a new window for each one. This is ordinarily no problem at all — you can still have as many PDFs open in Preview as you want; there will just be only one Preview icon in the dock or in the ⌘→ switcher.</p>
<p>But what if you want to open the same file twice? That&#8217;s not possible! And what about applications like VLC that only open one window at a time? There, each new video you start playing replaces the previous one.</p>
<p>Opening a file with <code>open -n</code> changes all that. And my life is now happier for it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.benjaminfenster.com/2011/02/open-two-instances-of-mac-os-x-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Itty Bitty Applications Only?</title>
		<link>http://blog.benjaminfenster.com/2011/01/itty-bitty-applications-only/</link>
		<comments>http://blog.benjaminfenster.com/2011/01/itty-bitty-applications-only/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 14:04:00 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[WTF]]></category>

		<guid isPermaLink="false">http://blog.benjaminfenster.com/?p=1869</guid>
		<description><![CDATA[Oh, hosting provider. I understand why you want to impose a limit on how much memory PHP applications can use on your servers, but you may be taking it just a little too far: Fatal error: Allowed memory size of 64 bytes exhausted (tried to allocate 54 bytes) For the non-programmers out there, that means [...]]]></description>
			<content:encoded><![CDATA[<p>Oh, hosting provider. I understand why you want to impose a limit on how much memory PHP applications can use on your servers, but you may be taking it just a little too far:</p>
<blockquote><p><strong>Fatal error</strong>: Allowed memory size of 64 bytes exhausted (tried to allocate 54 bytes)</p></blockquote>
<p>For the non-programmers out there, that means the application is asking for 54 more bytes of memory to store some information, but is being told it&#8217;s already used up the entire 64 bytes available to the <em>entire application</em>.</p>
<p>To put that in context, that <em>error message</em> (having 71 letters, spaces, and punctuation marks) takes up 71 bytes. So 64 bytes isn&#8217;t even enough to store a single error message, much less an entire application.</p>
<p>Put another way, when VisiCalc (often described as the &#8220;first killer app&#8221; for personal computers) came out in 1979, it wouldn&#8217;t run on low-end Apple II computers since they had only 16,384 bytes of memory available.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.benjaminfenster.com/2011/01/itty-bitty-applications-only/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cuckoo&#8217;s Egg</title>
		<link>http://blog.benjaminfenster.com/2010/07/cuckoos-egg/</link>
		<comments>http://blog.benjaminfenster.com/2010/07/cuckoos-egg/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 20:51:47 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.benjaminfenster.com/?p=1646</guid>
		<description><![CDATA[Clifford Stoll wrote The Cuckoo&#8217;s Egg in 1989, telling the true story of how he started investigating 75¢ of computer time nobody had paid for and ended up catching an international hacker passing through his computers to gain access to military secrets. The classic story is a fascinating mix of technical detail and the thrilling [...]]]></description>
			<content:encoded><![CDATA[<p>Clifford Stoll wrote <em>The Cuckoo&#8217;s Egg</em> in 1989, telling the true story of how he started investigating 75¢ of computer time nobody had paid for and ended up catching an international hacker passing through his computers to gain access to military secrets. The classic story is a fascinating mix of technical detail and the thrilling action of hunting an invisible criminal through the phone lines.</p>
<p>My favorite passage, though, comes at the very end. After the overseas spy is caught and brought to justice, another hacker slips into Stoll&#8217;s system and for a moment the whole process starts over again. Stoll writes:</p>
<blockquote><p>He got in through an unprotected astronomy computer run by a couple of infrared astronomers. They didn&#8217;t care about security . . . they just needed to connect to the network. Because I exchange programs with them, we&#8217;d set up our systems to work as one—you didn&#8217;t need a password to move from their computer to mine.</p>
<p>&#8230;</p>
<p>A couple days later the SOB called me. Said his name was Dave. From Australia. &#8220;I broke in to show that your security isn&#8217;t very good.&#8221;</p>
<p>&#8220;But I don&#8217;t want to secure my computer,&#8221; I replied. &#8220;I trust other astronomers.&#8221;</p></blockquote>
<p>And that&#8217;s the moral, as true today as in the 1980s. We don&#8217;t <em>want</em> to secure most systems. Certainly I wouldn&#8217;t want my online bank account accessible to common thieves, but a database of research or a casual blog shouldn&#8217;t require elaborate protective measures.</p>
<p>This is just as true in the physical world. I wouldn&#8217;t put my valuables in a bank vault with no lock, but the classroom doors where I went to college were always open.</p>
<p>Unfortunately, in software0 leaving any door unlocked can grant access to resources beyond the application itself, so we sink a fortune into securing even the most trivial of software against all imaginable attacks. That&#8217;s a high price to pay for protection against the pranks of mischievous hackers.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.benjaminfenster.com/2010/07/cuckoos-egg/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Submit Sully</title>
		<link>http://blog.benjaminfenster.com/2009/12/submit-sully/</link>
		<comments>http://blog.benjaminfenster.com/2009/12/submit-sully/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 00:57:44 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[WTF]]></category>

		<guid isPermaLink="false">http://blog.benjaminfenster.com/?p=1358</guid>
		<description><![CDATA[Found in an old bit of code a former student in my department wrote: &#60;form action=&#8221;&#8230;&#8221; method=&#8221;post&#8221; onsubmit=&#8221;myfun();myfun2();myfun3();return submitSully;&#8221;&#62; If it just called myfun(), myfun2(), and myfun3(), and then returned Sully, that would be mundane.  But it calls myfun(), myfun2(), and myfun3(), and returns submitSully, and that&#8217;s just priceless.]]></description>
			<content:encoded><![CDATA[<p>Found in an old bit of code a former student in my department wrote:</p>
<blockquote><p>&lt;form action=&#8221;&#8230;&#8221; method=&#8221;post&#8221; onsubmit=&#8221;myfun();myfun2();myfun3();return submitSully;&#8221;&gt;</p></blockquote>
<p>If it just called myfun(), myfun2(), and myfun3(), and then returned Sully, that would be mundane.  But it calls myfun(), myfun2(), and myfun3(), and returns <em>submitSully</em>, and that&#8217;s just priceless.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.benjaminfenster.com/2009/12/submit-sully/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Modern Medicine Through JavaScript</title>
		<link>http://blog.benjaminfenster.com/2009/10/modern-medicine-through-javascript/</link>
		<comments>http://blog.benjaminfenster.com/2009/10/modern-medicine-through-javascript/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 20:10:16 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[WTF]]></category>

		<guid isPermaLink="false">http://blog.benjaminfenster.com/?p=1292</guid>
		<description><![CDATA[I love a medical school that gives online tests (quizzes, maybe?) and evaluates the results through JavaScript.  I especially love when it uses this logic to do it: if(correct) return true; else { if(guess &#60; 2) { alert("That is not correct."); guess = guess + 1; return false; } else { alert("You have guessed incorrectly, [...]]]></description>
			<content:encoded><![CDATA[<p>I love a medical school that gives online tests (quizzes, maybe?) and evaluates the results through JavaScript.  I especially love when it uses this logic to do it:</p>
<blockquote>
<pre>if(correct) return true;
else {
  if(guess &lt; 2) {
    alert("That is not correct.");
    guess = guess + 1;
    return false;
  } else {
    alert("You have guessed incorrectly, but may move on.");
    return true;
  }
}</pre>
</blockquote>
<p>I hope my (hypothetical) surgeon works the same way.  &#8220;You&#8217;ve removed three organs.  None of them were right, but you can send him home now anyway.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.benjaminfenster.com/2009/10/modern-medicine-through-javascript/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Self-Creating Tables</title>
		<link>http://blog.benjaminfenster.com/2009/07/self-creating-tables/</link>
		<comments>http://blog.benjaminfenster.com/2009/07/self-creating-tables/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 12:45:30 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.benjaminfenster.com/?p=1106</guid>
		<description><![CDATA[I recently tried creating a new database table only to learn a table with that name exists already. [me@mysql db] &#62; CREATE TABLE log_search ( log_search_id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL , search VARCHAR(255) , created_by VARCHAR(128), created_on DATETIME) ENGINE=InnoDB CHARSET=utf8; ERROR 1050 (42S01): Table 'log_search' already exists [me@mysql db] &#62; DESC log_search; +---------------+---------------------+------+-----+---------------------+----------------+ &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>I recently tried creating a new database table only to learn a table with that name exists already.</p>
<blockquote>
<pre>[me@mysql db] &gt; CREATE TABLE log_search (
log_search_id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL
, search VARCHAR(255)
, created_by VARCHAR(128), created_on DATETIME)
 ENGINE=InnoDB CHARSET=utf8;
ERROR 1050 (42S01): Table 'log_search' already exists
[me@mysql db] &gt; DESC log_search;
+---------------+---------------------+------+-----+---------------------+----------------+
| Field         | Type                | Null | Key | Default             | Extra          |
+---------------+---------------------+------+-----+---------------------+----------------+
| log_search_id | bigint(20) unsigned |      | PRI | NULL                | auto_increment |
| search        | varchar(255)        |      |     |                     |                |
| created_on    | datetime            |      |     | 0000-00-00 00:00:00 |                |
| created_by    | varchar(128)        |      |     |                     |                |
+---------------+---------------------+------+-----+---------------------+----------------+
4 rows in set (0.00 sec)</pre>
</blockquote>
<p>I love naming conventions!  My favorite part of programming is when I start to write a routine only to learn I already wrote it months ago in preparation for what I knew I&#8217;d be doing now.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.benjaminfenster.com/2009/07/self-creating-tables/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Verizon LG Bluetooth</title>
		<link>http://blog.benjaminfenster.com/2009/06/verizon-lg-bluetooth/</link>
		<comments>http://blog.benjaminfenster.com/2009/06/verizon-lg-bluetooth/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 00:14:26 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Anecdotes]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.benjaminfenster.com/?p=1056</guid>
		<description><![CDATA[I learned today, as evidenced in my previous post, that I can easily transfer pictures from my LG phone to my iMac using Bluetooth.  Since this was not immediately obvious to me, I&#8217;ll now share the steps I took for the benefit of all mankind. First, I made the phone discoverable (Settings &#62; Bluetooth Menu [...]]]></description>
			<content:encoded><![CDATA[<p>I learned today, as evidenced in my previous post, that I can easily transfer pictures from my LG phone to my iMac using Bluetooth.  Since this was not immediately obvious to me, I&#8217;ll now share the steps I took for the benefit of all mankind.</p>
<p>First, I made the phone discoverable (Settings &gt; Bluetooth Menu &gt; Options &gt; Discovery Mode &gt; On)</p>
<p>Next, on my iMac I opened the Bluetooth System Preferences pane and clicked the &#8220;+&#8221; button at the bottom of my list of devices.  After some searching, it discovered my phone and let me select it.  At some point I got to a screen that implied the only thing I could do with this phone was use its Internet connection.  False!</p>
<p>I ignored that screen entirely — in fact, I quit out of the setup wizard at that point — and went back to the Bluetooth System Preferences pane, which now included my phone in the list of devices.</p>
<p>Clicking the &#8220;gear&#8221; icon at the bottom of that list, I chose &#8220;Browse Device.&#8221;</p>
<p>There were my files!</p>
<p>It also looks like I could transfer new MIDI ringtones to my phone in that way, although like a civilized adult I want my phone to <a href="http://www.xkcd.com/479/">make a ringing sound when someone calls me</a>.</p>
<div id="attachment_1054" class="wp-caption alignright" style="width: 230px"><a href="http://blog.benjaminfenster.com/wp-content/uploads/2009/06/fail-iMac-phone-connected.png"><img class="size-full wp-image-1054" title="iMac &amp; Phone: Connected or Not?" src="http://blog.benjaminfenster.com/wp-content/uploads/2009/06/fail-iMac-phone-connected.png" alt="iMac &amp; Phone: Connected or Not?" width="220" height="46" /></a><p class="wp-caption-text">Connected?</p></div>
<p>You can see that the iMac was somewhat conflicted about whether the phone was connected, but otherwise the whole thing went quite smoothly!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.benjaminfenster.com/2009/06/verizon-lg-bluetooth/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lines of Code?  We Don&#8217;t Need No Stinking Lines of Code</title>
		<link>http://blog.benjaminfenster.com/2009/06/lines-of-code-we-dont-need-no-stinking-lines-of-code/</link>
		<comments>http://blog.benjaminfenster.com/2009/06/lines-of-code-we-dont-need-no-stinking-lines-of-code/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 01:49:26 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.benjaminfenster.com/?p=1033</guid>
		<description><![CDATA[Let&#8217;s look at an old application my department started in 2001 and developed sporadically until finally launching it in 2007: [me@desktop old]$ find . &#124; grep -E '(php&#124;js)$' &#124; xargs wc -l &#124; tail -n 1 53063 total [me@desktop old]$ find . &#124; grep -E '(html&#124;css)$' &#124; xargs wc -l &#124; tail -n 1 9726 [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s look at an old application my department started in 2001 and developed sporadically until finally launching it in 2007:</p>
<blockquote><p><code>[me@desktop old]$ find . | grep -E '(php|js)$' | xargs wc -l | tail -n 1</code><br />
<code>53063 total</code><br />
<code>[me@desktop old]$ find . | grep -E '(html|css)$' | xargs wc -l | tail -n 1</code><br />
<code>9726 total</code></p></blockquote>
<p>Now let&#8217;s switch over to the replacement application I started in January, 2009 and launched in May, 2009:</p>
<blockquote><p><code>[me@desktop new]$ find . | grep -E '(php|js)$' | xargs wc -l | tail -n 1<br />
5955 total<br />
[me@desktop new]$ find . | grep -E '(html|css)$' | xargs wc -l | tail -n 1<br />
2302 total</code></p></blockquote>
<p>For those unfamiliar with <code>find</code>, <code>grep</code>, regular expressions, <code>xargs</code>, or <code>tail</code>, that means the old application took 53,063 lines of PHP and JavaScript to do what I did in 5,955.  The old used 9,726 lines of HTML and CSS; I used only 2,302.</p>
<p>So, basically I had fewer total lines of content in the entire rewritten application than its predecessor had merely of markup and styles.  That&#8217;s fantastic!</p>
<p>Of course, some of you are thinking that&#8217;s just because I write much longer lines of code, right?  And you naturally want me to compute the average number of characters per line used in each application to compare, right?  And you demand — <em>demand</em> — that it be done with a single command chain in UNIX?  As you wish!</p>
<blockquote><p><code>[me@desktop old]$ (find . | grep -E '(html|css|php|js)$' | tee temp | xargs wc -l | tail -n 1 | awk '{print $1}' ; cat temp | xargs wc -c | tail -n 1 | awk '{print $1}') | sed 'N;s/\n/ /' | awk '{print $2 " / " $1 " = " $2 / $1}'<br />
1523405 / 51063 = 29.8338</code></p></blockquote>
<blockquote><p><code>[me@desktop new]$ (find . | grep -E '(html|css|php|js)$' | tee temp | xargs wc -l | tail -n 1 | awk '{print $1}' ; cat temp | xargs wc -c | tail -n 1 | awk '{print $1}') | sed 'N;s/\n/ /' | awk '{print $2 " / " $1 " = " $2 / $1}'<br />
252837 / 8257 = 30.6209</code></p></blockquote>
<p>See?  I used only one extra character per line!  On the other hand, I spent a good 30 minutes writing that command: 1 minute composing what I put there and the other 29 trying to figure out a way to do it without either running the <code>find</code> twice or writing anything to a temp file.  (You&#8217;ll notice I gave up and threw in a <code>tee</code> halfway through.)</p>
<p><strong>UPDATE: </strong>I was too focused on the chaining problem to recognize that I could just have <code>wc</code> calculate the number of characters and lines at the same time.  This would have worked just as well, with no temp file, and with far less complexity:</p>
<blockquote><p><code>find . | grep -E '(php|js|html|css)$' | xargs wc -l -c | tail -n 1 | awk '{print $2 " / " $1 " = " $2/$1}'</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.benjaminfenster.com/2009/06/lines-of-code-we-dont-need-no-stinking-lines-of-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

