Walter Smith, software guyhttp://waltersmith.us/2010-09-14T17:31:00+00:00Walter SmithCat vs. computerhttp://waltersmith.us/articles/cat-vs-computer2010-09-14T17:31:00+00:002010-09-14T17:31:00+00:00Walter Smith<p>This afternoon I was iChatting with my excellent co-founder <a href="http://jonathanischwartz.wordpress.com/">Jonathan</a> when my video started to go all jittery. I checked iStat and saw that <code>kernel_task</code> was using about 200% <span class="caps">CPU</span> time. That seemed…odd. Since the chat was rapidly becoming unusable, I signed off temporarily to debug the problem.</p>
<p>At first I blamed Time Machine, which happened to be doing a backup at the time. I’ve seen some crazy <span class="caps">CPU</span> usage when Time Machine is “cleaning up”. But stopping the backup didn’t help. In fact, rebooting didn’t help. Something very weird was going on.</p>
<p>I thought to myself, “this is a job for DTrace!” and spent an enjoyable ten minutes poking around in DTrace-land. Eventually I ran across <a href="http://www.brendangregg.com/DTrace/hotkernel">hotkernel.pl</a> which, despite its age, still seems to work. It told me most of the time was going into the function <code>machine_idle</code>. Uh, what?</p>
<p><img src="http://waltersmith.us/blog/charlie%20and%20apple-300.jpg" class="left" alt="" /></p>
<p>Now, we have four cats, and most of them have figured out that a MacBook Pro is a lovely, warm place to sleep, and one of them happened to be sleeping on it. Perhaps due to my cursing, she decided to find a more peaceful spot for a nap. As soon as she left, <code>kernel_task</code> <span class="caps">CPU</span> time started going down, and so did the fan speed. Pretty soon everything was back to normal.</p>
<p>Clearly the cat was to blame (so often the case). She had blocked the ventilation on my MacBook and somehow caused this bizarre behavior. Doing further research using the google, I discovered the possible answer—though I’m not sure it has been confirmed by Apple. Apparently, when the MacBook Air came out, there was some controversy because it was so easy to overheat it (e.g., by playing 1080p video for two minutes), and it reacted by shutting down processor cores to conserve power. “They” say that Apple issued a patch so that instead of shutting down a core, the kernel scheduler just stops using it, and the unused time shows up under <code>kernel_task</code>. “Their” theory is that it looks better to customers than a disabled core. An amusing case of engineering by PR, if true.</p>
<p>Now I’m wondering if this situation is detectable in software, so next time I can just have an alert box that tells me what’s really going on.</p>
<p><img src="http://waltersmith.us/blog/overtemp.png" alt="" /></p>Best coffee shop for geekshttp://waltersmith.us/articles/best-coffee-shop-for-geeks2010-07-06T18:35:00+00:002010-07-06T18:35:00+00:00Walter Smith<p><img src="http://waltersmith.us/blog/roasting-plant.jpg" alt="" /></p>
<p class="credit">Photo by <a href="http://www.roastingplant.com/">Roasting Plant</a></p>
<p>On a visit to New York City last week I had the pleasure of stopping by the Lower East Side branch of <a href="http://www.roastingplant.com/">Roasting Plant</a>, which has to be the ideal coffee place for geeky perfectionists like myself. The coffee is roasted in small batches on-site. When you place your order, the counter clerk touches the screen, and <em>whoosh!</em> a measured amount of your selected coffee beans are whisked through pneumatic tubes over your head, directly into an automated espresso machine that grinds, tamps, and brews the coffee. It’s like the canteen at the Willy Wonka factory. Oh, and the coffee tastes good, too.</p>Simple Rails app confighttp://waltersmith.us/articles/simple-rails-app-config2010-07-05T14:56:00+00:002010-07-05T14:56:00+00:00Walter Smith<p>Where do you put the global settings for your Rails application? There are several “app config” plugins out there, but they seem too complicated to me. I just want the following:</p>
<ul>
<li>Store configuration data in a YAML file checked into Git.</li>
<li>Store more sensitive configuration data in environment vars or Heroku config.</li>
<li>Simple access, no magic: <code>AppConfig['key.subkey']</code></li>
</ul>
<p>This is so simple it isn’t even a plugin, just a file to stick in the <code>lib</code> dir and require.</p>
<p><noscript><a href="http://gist.github.com/464723">See source code gist</a></noscript><script src="http://gist.github.com/464723.js"></script></p>
Batch-editing JPEG headershttp://waltersmith.us/articles/batch-editing-jpeg-headers2006-01-27T12:00:00+00:002006-01-27T12:00:00+00:00Walter Smith<p>I am going through the >3000 pictures we took in Antarctica, and noticed that some of them were way out of order. It turns out that one of the cameras' clocks was set 12 hours off. Then I realized the other camera was set to Pacific time anyway, so really it was five hours off.</p>
<p>A few minutes of searching around later, I found <a href="http://www.sentex.net/~mwandel/jhead/">jhead, a command-line JPEG header tool</a> with a very convenient function:</p>
<p><code>jhead -ta+5:00 *.jpg</code></p>
<p>This adds five hours to the Date Taken of all the JPG files in a directory. Spiffy. A shout out to <a href="http://www.sentex.net/~mwandel/">Matthias Wandel</a> for making this free tool available. His <a href="http://www.sentex.net/~mwandel/organ/organ.html">pipe organ</a> looks pretty neat too! There’s something about <a href="http://www-cs-faculty.stanford.edu/~knuth/organ.html">computer folks</a> and pipe organs…</p>