<?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"
	>

<channel>
	<title>One Man's Walk in work</title>
	<atom:link href="http://onemanswalk.com/work/feed" rel="self" type="application/rss+xml" />
	<link>http://onemanswalk.com/work</link>
	<description>jeremy lightsmith on agile, ruby, and consulting</description>
	<pubDate>Sun, 24 Aug 2008 19:44:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>A New Blog, Git, &#038; Capistrano</title>
		<link>http://onemanswalk.com/work/2008/08/24/a-new-blog-git-capistrano/</link>
		<comments>http://onemanswalk.com/work/2008/08/24/a-new-blog-git-capistrano/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 19:44:06 +0000</pubDate>
		<dc:creator>jeremy</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://onemanswalk.com/work/?p=63</guid>
		<description><![CDATA[	I&#8217;ve had my fun with ruby.

	I wanted to learn ruby, so I wrote myself a blog.  Then, I wanted to learn rails, so I migrated it to rails.  Then, the spam was too much, so I migrated to Typo.  Then, I couldn&#8217;t take Typo&#8217;s memory footprint, so I moved to Mephisto.

	But you [...]]]></description>
			<content:encoded><![CDATA[	<p>I&#8217;ve had my fun with ruby.</p>

	<p>I wanted to learn ruby, so I wrote myself a blog.  Then, I wanted to learn rails, so I migrated it to rails.  Then, the spam was too much, so I migrated to Typo.  Then, I couldn&#8217;t take Typo&#8217;s memory footprint, so I moved to Mephisto.</p>

	<p>But you know what?  Even Mephisto is a pain to deploy, and is still a resource hog.  It&#8217;s kind of the nature of ruby and rails apps.  And what&#8217;s the benefit to justify the cost?  Aren&#8217;t there other more mature, stable, better supported and more flexible blog engines in other languages?</p>

	<p>&#8230;yes, there are like 50 of them.</p>

	<p>So I&#8217;ve migrated yet again, this time to Wordpress.</p>

	<p>I&#8217;m really happy with it, but I did have some cool toys in my rails world that I didn&#8217;t want to give up.  I can use my own machine as a staging environment to blog changes.  I can also deploy with a simple &#8220;cap deploy&#8221;.</p>

	<p>So.</p>

	<p>My entire website now lives on <a href="http://github.com/jeremylightsmith/blog" title="">github</a> and I use capistrano to deploy it after making edits locally.  It looks something like this:</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="bash">git commit -m <span style="color: #ff0000;">&quot;...&quot;</span>
git push
&nbsp;
cap pull</pre></div></div>
</p>



	<p>And to give you an idea of the goodness that is ruby and cap, I also wrote a script to pull the databases on my server down to my staging environment.  After all, what&#8217;s the point of staging if it uses different data.  Using looks something like this:</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="bash">cap backup
&nbsp;
rake db:pull db:restore</pre></div></div>
</p>



	<p>If you want to see how this is done, check out <a href="http://github.com/jeremylightsmith/blog" title="">repository</a></p>
 ]]></content:encoded>
			<wfw:commentRss>http://onemanswalk.com/work/2008/08/24/a-new-blog-git-capistrano/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Making Line Up / Down not suck in Textmate</title>
		<link>http://onemanswalk.com/work/2008/08/05/making-line-up-down-not-suck-in-textmate/</link>
		<comments>http://onemanswalk.com/work/2008/08/05/making-line-up-down-not-suck-in-textmate/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 00:46:00 +0000</pubDate>
		<dc:creator>jeremy</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[	I think I blew Steve Conover&#8217;s mind last week.

	He, like me, and every other sane rational person I&#8217;ve ever met, thinks that when you say &#8220;line up&#8221; or &#8220;line down&#8221; in a text editor, it should take the line(s) you are currently on and move them up, in their entirety.  Furthermore, that if you [...]]]></description>
			<content:encoded><![CDATA[	<p>I think I blew <a href="http://pivots.pivotallabs.com/users/steve/blog" title="">Steve Conover&#8217;s</a> mind last week.</p>

	<p>He, like me, and every other sane rational person I&#8217;ve ever met, thinks that when you say &#8220;line up&#8221; or &#8220;line down&#8221; in a text editor, it should take the line(s) you are currently on and move them up, in their entirety.  Furthermore, that if you press &#8220;line up&#8221; 5 times, the line(s) you are currently on should move up 5 lines.</p>

	<p>Textmate, as much as I love it, does not do this, and this has long been a source of contention and strife among my colleagues at <a href="http://pivotallabs.com/" title="">Pivotal</a>.</p>

	<p>This, however, is a story with a happy ending.  Last week, Steve and I were pairing on Textmate, and he was complaining that line up / down wasn&#8217;t working properly.  A couple hours later, I had a brilliant insight.  This is how you fix Textmate&#8217;s line up / down :</p>

	<p>Pull up textmate and type :</p>

<pre>
command-option-M
command-shift-L
command-control-up arrow
command-option-M
control-option-m
</pre>

	<p>This will start recording a macro, select the current line, move the current line up, stop recording the macro, and then save the macro.</p>

	<p>Next, name your macro &#8220;line up&#8221; in the dialog that just popped up, and give it a key equivalent of command-control-up arrow.</p>

	<p>Congratulations, you just fixed line up!</p>

	<p>Now let&#8217;s do the same with line down :</p>

<pre>
command-option-M
command-shift-L
command-control-down arrow
command-option-M
control-option-m
</pre>

	<p>This time, name it &#8220;line down&#8221;, and give it a key equivalent of command-control-down arrow.</p>

	<p>You of course don&#8217;t have to do all this with keyboard shortcuts, but it&#8217;s really impressive if you do <img src='http://onemanswalk.com/work/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>

 ]]></content:encoded>
			<wfw:commentRss>http://onemanswalk.com/work/2008/08/05/making-line-up-down-not-suck-in-textmate/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Eventual Consistency, or things will all work out&#8230;eventually</title>
		<link>http://onemanswalk.com/work/2008/08/05/eventual-consistency-or-things-will-all-work-out-eventually/</link>
		<comments>http://onemanswalk.com/work/2008/08/05/eventual-consistency-or-things-will-all-work-out-eventually/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 00:12:00 +0000</pubDate>
		<dc:creator>jeremy</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[	So we&#8217;re working with Amazon&#8217;s SimpleDB.  It&#8217;s pretty sweet, though the ruby libraries for it are still a bit primitive.  One of the problems you run up against when you&#8217;re writing integration tests against it is eventual consistency.

	Take this test :

	
it &#34;should save&#34; do
  customer = Customer.create!&#40;:name =&#62; 'bob', :email =&#62; 'bob@example.com'&#41;
 [...]]]></description>
			<content:encoded><![CDATA[	<p>So we&#8217;re working with <a href="http://www.amazon.com/SimpleDB-AWS-Service-Pricing/b?ie=UTF8&#038;node=342335011" title="">Amazon&#8217;s SimpleDB</a>.  It&#8217;s pretty sweet, though the ruby libraries for it are still a bit primitive.  One of the problems you run up against when you&#8217;re writing integration tests against it is eventual consistency.</p>

	<p>Take this test :</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby">it <span style="color:#996600;">&quot;should save&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  customer = Customer.<span style="color:#9900CC;">create</span>!<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'bob'</span>, <span style="color:#ff3333; font-weight:bold;">:email</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'bob@example.com'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  customer = Customer.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>customer.<span style="color:#9900CC;">key</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  customer.<span style="color:#9900CC;">name</span>.<span style="color:#9900CC;">should</span> == <span style="color:#996600;">'bob'</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>
</p>



	<p>The way SimpleDB works, you&#8217;re assured that Customer.find will work&#8230;eventually, but not right away.</p>

	<p>For a couple days we contented ourselves to just run the integration tests a couple times until they didn&#8217;t error out.  But that got old.</p>

	<p>Enter &#8220;eventually&#8221; :</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby">it <span style="color:#996600;">&quot;should save&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  customer = Customer.<span style="color:#9900CC;">create</span>!<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'bob'</span>, <span style="color:#ff3333; font-weight:bold;">:email</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'bob@example.com'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  customer = eventually <span style="color:#006600; font-weight:bold;">&#123;</span> Customer.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>customer.<span style="color:#9900CC;">key</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
  customer.<span style="color:#9900CC;">name</span>.<span style="color:#9900CC;">should</span> == <span style="color:#996600;">'bob'</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>
</p>



	<p>It&#8217;s a very simple method (below) that just retries the passed in block until it succeeds, timing out after 10 tries.  Super simple, works like a charm.  Thank you ruby.</p>

	<p>Here&#8217;s the source :</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">def</span> eventually<span style="color:#006600; font-weight:bold;">&#40;</span>tries = <span style="color:#006666;">0</span>, <span style="color:#006600; font-weight:bold;">&amp;</span>block<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">yield</span>
<span style="color:#9966CC; font-weight:bold;">rescue</span>
  <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#9966CC; font-weight:bold;">if</span> tries <span style="color:#006600; font-weight:bold;">&gt;</span>= <span style="color:#006666;">10</span>
  <span style="color:#CC0066; font-weight:bold;">sleep</span> <span style="color:#006666;">0.5</span>
  eventually<span style="color:#006600; font-weight:bold;">&#40;</span>tries <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">1</span>, <span style="color:#006600; font-weight:bold;">&amp;</span>block<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>
</p>



	<p>I will say, I can&#8217;t help but smile every time I write &#8220;eventually&#8221; in a test&#8230; <img src='http://onemanswalk.com/work/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
 ]]></content:encoded>
			<wfw:commentRss>http://onemanswalk.com/work/2008/08/05/eventual-consistency-or-things-will-all-work-out-eventually/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Linking Delicious Library to Your Movies</title>
		<link>http://onemanswalk.com/work/2008/07/25/linking-delicious-library-to-your-movies/</link>
		<comments>http://onemanswalk.com/work/2008/07/25/linking-delicious-library-to-your-movies/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 15:47:00 +0000</pubDate>
		<dc:creator>jeremy</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[	If you&#8217;re like me, you value traveling light.  If you&#8217;re like me, anything that can live in digital form does.  I haven&#8217;t seen most of the actual DVD&#8217;s I own for quite some time now.  But the movies on them all live on a hard drive that&#8217;s hooked up to my television. [...]]]></description>
			<content:encoded><![CDATA[	<p>If you&#8217;re like me, you value traveling light.  If you&#8217;re like me, anything that can live in digital form does.  I haven&#8217;t seen most of the actual <span class="caps">DVD</span>&#8217;s I own for quite some time now.  But the movies on them all live on a hard drive that&#8217;s hooked up to my television.  I love the instant gratification.  I love that I can download a movie to my laptop and watch it on the plane.</p>

	<p><a href="http://www.delicious-monster.com/" title="">Delicious Library</a> makes this even cooler.  As much as I love having everything digital, I miss being able to take a quick glance at 100 covers and recognize the one I want.  I miss the association between images and memories.  Delicious gives this back to me.</p>

	<p>However, it&#8217;d be really cool if I could go browsing in my  delicious &#8220;library&#8221;, find the movie I want, and double click it to play.  Turns out you can easily extend the program with applescript, and a couple hours after I decided such a script didn&#8217;t already exist on the interweb, it now does.</p>

	<p>This applescript will open vlc with the file associated to a media object in delicious.  If there isn&#8217;t one already, it will prompt you for this file and then remember it for next time.  It&#8217;s really simple, and happy <img src='http://onemanswalk.com/work/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />

<div class="wp_syntax"><div class="code"><pre class="applescript"><span style="color: #808080; font-style: italic;">-- this will play the currently selected file in vlc using either </span>
<span style="color: #808080; font-style: italic;">-- the associated url or prompting you to find the file on disk</span>
&nbsp;
<span style="color: #b1b100;">tell</span> <span style="color: #000000; font-weight: bold;">first</span> document <span style="color: #b1b100;">of</span> application <span style="color: #ff0000;">&quot;Delicious Library 2&quot;</span>
    <span style="color: #b1b100;">set</span> selectedMedia <span style="color: #b1b100;">to</span> selected media
    <span style="color: #b1b100;">repeat</span> <span style="color: #b1b100;">with</span> selectedMedium <span style="color: #b1b100;">in</span> selectedMedia
        <span style="color: #b1b100;">set</span> movieUrl <span style="color: #b1b100;">to</span> associated URL <span style="color: #b1b100;">of</span> selectedMedium
&nbsp;
        <span style="color: #b1b100;">if</span> movieUrl starts <span style="color: #b1b100;">with</span> <span style="color: #ff0000;">&quot;file://&quot;</span> <span style="color: #b1b100;">then</span>
            <span style="color: #b1b100;">set</span> movieFile <span style="color: #b1b100;">to</span> rich text <span style="color: #cc66cc;">8</span> <span style="color: #000000; font-weight: bold;">through</span> <span style="color: #b1b100;">end</span> <span style="color: #b1b100;">of</span> movieUrl
        <span style="color: #b1b100;">else</span>
            <span style="color: #b1b100;">set</span> movieFile <span style="color: #b1b100;">to</span> <span style="color: #66cc66;">&#40;</span>choose file <span style="color: #b1b100;">with</span> prompt <span style="color: #ff0000;">&quot;Find the file for &quot;</span> \
                                            <span style="color: #66cc66;">&amp;</span> name <span style="color: #b1b100;">of</span> selectedMedium <span style="color: #66cc66;">&amp;</span> <span style="color: #ff0000;">&quot;:&quot;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
            <span style="color: #b1b100;">set</span> associated URL <span style="color: #b1b100;">of</span> selectedMedium <span style="color: #b1b100;">to</span> <span style="color: #ff0000;">&quot;file://&quot;</span> <span style="color: #66cc66;">&amp;</span> movieFile
        <span style="color: #b1b100;">end</span> <span style="color: #b1b100;">if</span>
&nbsp;
        <span style="color: #b1b100;">tell</span> application <span style="color: #ff0000;">&quot;VLC&quot;</span>
            activate
            <span style="color: #000066;">open</span> movieFile
            fullscreen
        <span style="color: #b1b100;">end</span> <span style="color: #b1b100;">tell</span>
    <span style="color: #b1b100;">end</span> <span style="color: #b1b100;">repeat</span>
<span style="color: #b1b100;">end</span> <span style="color: #b1b100;">tell</span></pre></div></div>
</p>



 &#8211; thanks <a href="http://brokenbuild.com/" title="">Wes</a> for pointing me to such a cool program!
 ]]></content:encoded>
			<wfw:commentRss>http://onemanswalk.com/work/2008/07/25/linking-delicious-library-to-your-movies/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PhpUnit for TextMate</title>
		<link>http://onemanswalk.com/work/2008/07/18/phpunit-for-textmate/</link>
		<comments>http://onemanswalk.com/work/2008/07/18/phpunit-for-textmate/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 23:55:00 +0000</pubDate>
		<dc:creator>jeremy</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[	Who would have thought I&#8217;d be doing php?

	Anyway, yesterday I found myself doing php and really wanting it to hurt less.  I downloaded a textmate bundle for phpunit from github.  It wasn&#8217;t quite what I wanted, so I forked it and hacked it, and made it work a bit more like the rspec [...]]]></description>
			<content:encoded><![CDATA[	<p>Who would have thought I&#8217;d be doing php?</p>

	<p>Anyway, yesterday I found myself doing php and really wanting it to hurt less.  I downloaded a <a href="http://github.com/meritt/phpunit-tmbundle" title="">textmate bundle for phpunit</a> from github.  It wasn&#8217;t quite what I wanted, so I forked it and hacked it, and made it work a bit more like the rspec bundle.</p>

	<p>It now has:</p>

	<p>Commands</p>
	<ul>
		<li>run tests (in current file)</li>
		<li>run single test</li>
	</ul>

	<p>Snippets</p>
	<ul>
		<li>test</li>
	</ul>

	<p>And much to my surprise, it was way easy to do.  All in ruby, all with specs testing it.</p>

	<p>This article was going to be telling all y&#8217;all to come over to <em>my</em> cool fork of phpunit, but I sent the original author a pull request yesterday, and I just looked, and he&#8217;s pulled all my changes.  Rock!</p>

	<p>So go forth and enjoy the goodness that an extensible editor like textmate, oss code like the phpunit bundle, and github can bring about.</p>

	<p><a href="http://github.com/meritt/phpunit-tmbundle" title=""><span class="caps">PHP</span>Unit.bundle for textmate</a></p>

 ]]></content:encoded>
			<wfw:commentRss>http://onemanswalk.com/work/2008/07/18/phpunit-for-textmate/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Clickable Stack Traces on your Rails Error Page</title>
		<link>http://onemanswalk.com/work/2008/04/30/clickable-stack-traces-on-your-rails-error-page/</link>
		<comments>http://onemanswalk.com/work/2008/04/30/clickable-stack-traces-on-your-rails-error-page/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 18:29:00 +0000</pubDate>
		<dc:creator>jeremy</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[	Wouldn&#8217;t it be nice if when an error happened in your application, you could not only see the stack trace, but click on a line and jump to the offending code?  This is not groundbreaking stuff, I know, I had this like 10 years ago in C++ and later Java fat clients, and I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[	<p>Wouldn&#8217;t it be nice if when an error happened in your application, you could not only see the stack trace, but click on a line and jump to the offending code?  This is not groundbreaking stuff, I know, I had this like 10 years ago in C++ and later Java fat clients, and I&#8217;m sure other languages &#038; IDEs had it too &#8211; but somehow in moving to writing web apps in Ruby, I lost it.</p>

	<p>I want it back damnit!</p>

	<p>Turns out it&#8217;s pretty easy to get back (at least it is if you use textmate) &#8211; check it out.</p>

	<h2>Custom Error Page</h2>

	<p>First, to get a custom error page for your project, add something like this to your application.rb :</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">def</span> rescue_action_locally<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>args<span style="color:#006600; font-weight:bold;">&#41;</span>
  render <span style="color:#ff3333; font-weight:bold;">:template</span>  <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;application/public_error&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:layout</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">alias</span> rescue_action_in_public render_action_locally</pre></div></div>
</p>



	<p>Note, if you&#8217;re using exception notifiable, you probably want to change the last line to something like :</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">alias</span> render_404 rescue_action_locally
<span style="color:#9966CC; font-weight:bold;">alias</span> render_500 rescue_action_locally</pre></div></div>
</p>



	<p>We use markaby, so our public_error template looks something like this; it&#8217;s probably a good idea to keep this simple and not use a layout, just in case the error came from the layout :</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby">html <span style="color:#9966CC; font-weight:bold;">do</span>
  head <span style="color:#9966CC; font-weight:bold;">do</span>
    title action_name
    stylesheet_link_tag <span style="color:#996600;">'error'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  body <span style="color:#9966CC; font-weight:bold;">do</span>
    div.<span style="color:#9900CC;">error</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      div.<span style="color:#9900CC;">message</span> <span style="color:#9966CC; font-weight:bold;">do</span>
        h1 <span style="color:#996600;">&quot;Whoops&quot;</span>
&nbsp;
        p <span style="color:#996600;">&quot;We detected an error.  Don't worry, though, 
we've been notified and we're on it.&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>
</p>




	<h2>Adding a Stack Trace w/ Links to the Error Page</h2>

	<p>So, it would be helpful to us for our error page to tell us more in our development and staging environments.  We do use exception notifiable, so we don&#8217;t actually need or want it to say anything else to a real user in production.  Adding this to our template, it now looks like this :</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby">html <span style="color:#9966CC; font-weight:bold;">do</span>
  head <span style="color:#9966CC; font-weight:bold;">do</span>
    title action_name
    stylesheet_link_tag <span style="color:#996600;">'error'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  body <span style="color:#9966CC; font-weight:bold;">do</span>
    div.<span style="color:#9900CC;">error</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      div.<span style="color:#9900CC;">message</span> <span style="color:#9966CC; font-weight:bold;">do</span>
        h1 <span style="color:#996600;">&quot;Whoops&quot;</span>
&nbsp;
        p <span style="color:#996600;">&quot;We detected an error.  Don't worry, though, 
we've been notified and we're on it.&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
      <span style="color:#9966CC; font-weight:bold;">if</span> RAILS_ENV != <span style="color:#996600;">'production'</span>
        div.<span style="color:#9900CC;">stack_trace</span> <span style="color:#9966CC; font-weight:bold;">do</span>
          h2 <span style="color:#996600;">&quot;Stack Trace&quot;</span>
          div <span style="color:#006600; font-weight:bold;">&#123;</span> link_to_code $!.<span style="color:#9900CC;">to_s</span>.<span style="color:#9900CC;">to_s</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;<span style="color:#000099;">\n</span>&quot;</span>, <span style="color:#996600;">&quot;
&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
          hr
          div <span style="color:#006600; font-weight:bold;">&#123;</span> link_to_code $!.<span style="color:#9900CC;">backtrace</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;
&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>
</p>



	<p>What&#8217;s that &#8220;link_to_code&#8221; method in there?</p>

	<p>It&#8217;s a method in application_helper that replaces any path with a textmate url to open up that file on your local system and jump to the offending line.  Check it out :</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">def</span> link_to_code<span style="color:#006600; font-weight:bold;">&#40;</span>text<span style="color:#006600; font-weight:bold;">&#41;</span>
  text.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\w\.<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">*</span>\<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#91;</span>\w\<span style="color:#006600; font-weight:bold;">/</span>\.<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\:<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>match<span style="color:#006600; font-weight:bold;">|</span>
    file = $<span style="color:#006666;">1</span>.<span style="color:#9900CC;">starts_with</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;/&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? $<span style="color:#006666;">1</span> : <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>RAILS_ROOT, $<span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    link_to match, <span style="color:#996600;">&quot;txmt://open?url=file://#{file}&amp;line=#{$2}&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>
</p>



	<p>That&#8217;s it.  Suddenly, stack traces are friendly again!</p>

 ]]></content:encoded>
			<wfw:commentRss>http://onemanswalk.com/work/2008/04/30/clickable-stack-traces-on-your-rails-error-page/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Cruise Control.rb is moving to Lighthouse</title>
		<link>http://onemanswalk.com/work/2008/04/23/cruise-control-rb-is-moving-to-lighthouse/</link>
		<comments>http://onemanswalk.com/work/2008/04/23/cruise-control-rb-is-moving-to-lighthouse/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 16:12:00 +0000</pubDate>
		<dc:creator>jeremy</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[	So, following rSpec&#8217;s example, we&#8217;re moving from JIRA to Lighthouse.  Check us out at http://cruisecontrolrb.lighthouseapp.com/

	I have to say I wasn&#8217;t thrilled about Jira.  It does everything, and it does it slowly, with a UI that is bloated at best.  Lighthouse, on the other hand, keeps it REALLY simple.  And does not [...]]]></description>
			<content:encoded><![CDATA[	<p>So, following rSpec&#8217;s example, we&#8217;re moving from <span class="caps">JIRA</span> to Lighthouse.  Check us out at <a href="http://cruisecontrolrb.lighthouseapp.com/" title="">http://cruisecontrolrb.lighthouseapp.com/</a></p>

	<p>I have to say I wasn&#8217;t thrilled about Jira.  It does everything, and it does it slowly, with a UI that is bloated at best.  Lighthouse, on the other hand, keeps it <span class="caps">REALLY</span> simple.  And does not a lot more than what we need.  It also just opened itself up for <span class="caps">OSS</span> projects (which is cool).</p>

	<p>How did we migrate all of our stories from <span class="caps">JIRA</span> to Lighthouse?  I thought you&#8217;d never ask.</p>

	<p>Lighthouse exposes a slick <span class="caps">RES</span>Tful <span class="caps">API</span> for managing your data.  I exported the <span class="caps">JIRA</span> issues into a csv file, wrote a short ruby script, waited about 5 minutes for it to run, and I was done.</p>

	<p>Here&#8217;s the script:</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'csv'</span>
&nbsp;
JiraIssue = <span style="color:#CC00FF; font-weight:bold;">Struct</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:issue_type</span>, <span style="color:#ff3333; font-weight:bold;">:key</span>, <span style="color:#ff3333; font-weight:bold;">:status</span>, <span style="color:#ff3333; font-weight:bold;">:assign_to</span>, 
                       <span style="color:#ff3333; font-weight:bold;">:summary</span>, <span style="color:#ff3333; font-weight:bold;">:description</span>, <span style="color:#ff3333; font-weight:bold;">:fix_version</span>, 
                       <span style="color:#ff3333; font-weight:bold;">:reporter</span>, <span style="color:#ff3333; font-weight:bold;">:priority</span>, <span style="color:#ff3333; font-weight:bold;">:original_estimate</span>, 
                       <span style="color:#ff3333; font-weight:bold;">:votes</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> load_issues<span style="color:#006600; font-weight:bold;">&#40;</span>csv_file<span style="color:#006600; font-weight:bold;">&#41;</span>
  header = <span style="color:#0000FF; font-weight:bold;">true</span>
  issues = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  CSV.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>csv_file, <span style="color:#996600;">'r'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>row<span style="color:#006600; font-weight:bold;">|</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> header
      header = <span style="color:#0000FF; font-weight:bold;">false</span>
    <span style="color:#9966CC; font-weight:bold;">else</span>
      issues <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> JiraIssue.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>row<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
  issues
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
issues = load_issues<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot;/jiraissues.csv&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># this code is just to examine what our JIRA data looks like</span>
<span style="color:#9966CC; font-weight:bold;">def</span> show<span style="color:#006600; font-weight:bold;">&#40;</span>issues, field<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{field} = #{issues.map{|i| i.send(field)}.uniq.inspect}&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
show issues, <span style="color:#ff3333; font-weight:bold;">:issue_type</span>
show issues, <span style="color:#ff3333; font-weight:bold;">:status</span>
show issues, <span style="color:#ff3333; font-weight:bold;">:assign_to</span>
show issues, <span style="color:#ff3333; font-weight:bold;">:fix_version</span>
show issues, <span style="color:#ff3333; font-weight:bold;">:reporter</span>
show issues, <span style="color:#ff3333; font-weight:bold;">:priority</span>
show issues, <span style="color:#ff3333; font-weight:bold;">:original_estimate</span>
show issues, <span style="color:#ff3333; font-weight:bold;">:votes</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># these hashes translate between JIRA and Lighthouse</span>
states = <span style="color:#006600; font-weight:bold;">&#123;</span>
  <span style="color:#996600;">&quot;Open&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'open'</span>,
  <span style="color:#996600;">&quot;Resolved&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'resolved'</span>,
  <span style="color:#996600;">&quot;Closed&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'invalid'</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
users = <span style="color:#006600; font-weight:bold;">&#123;</span>
  <span style="color:#996600;">&quot;Unassigned&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">nil</span>,
  <span style="color:#996600;">&quot;Alexey Verkhovsky&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">10545</span>, 
  <span style="color:#996600;">&quot;Rolf Russell&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">17992</span>, 
  <span style="color:#996600;">&quot;Jeremy Stell-Smith&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">10638</span>, 
  <span style="color:#996600;">&quot;Zhang Lin&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">nil</span>, 
  <span style="color:#996600;">&quot;Jeff Xiong&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">nil</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
milestones = <span style="color:#006600; font-weight:bold;">&#123;</span>
  <span style="color:#996600;">&quot;1&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">9885</span>,
  <span style="color:#996600;">&quot;1.1&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">9886</span>, 
  <span style="color:#996600;">&quot;1.2&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">9887</span>, 
  <span style="color:#996600;">&quot;1.3&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">9888</span>, 
  <span style="color:#996600;">&quot;1.4&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">9889</span>, 
  <span style="color:#996600;">&quot;<span style="color:#000099;">\3</span>02<span style="color:#000099;">\2</span>40 &quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">nil</span>, 
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot;/lib/lighthouse&quot;</span>
<span style="color:#9966CC; font-weight:bold;">include</span> Lighthouse
&nbsp;
Lighthouse.<span style="color:#9900CC;">account</span> = <span style="color:#996600;">&quot;cruisecontrolrb&quot;</span>
<span style="color:#008000; font-style:italic;"># enter your own user, password here...</span>
Lighthouse.<span style="color:#9900CC;">authenticate</span> <span style="color:#996600;">&quot;jeremystellsmith@gmail.com&quot;</span>, <span style="color:#996600;">&quot;*******&quot;</span> 
&nbsp;
issues.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>i<span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#008000; font-style:italic;"># enter your own project id here...</span>
  ticket = Ticket.<span style="color:#9900CC;">new</span> <span style="color:#ff3333; font-weight:bold;">:project_id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">9150</span>
&nbsp;
  ticket.<span style="color:#9900CC;">title</span> = i.<span style="color:#9900CC;">summary</span>
  ticket.<span style="color:#9900CC;">body</span> = i.<span style="color:#9900CC;">description</span>
  ticket.<span style="color:#9900CC;">state</span> = states<span style="color:#006600; font-weight:bold;">&#91;</span>i.<span style="color:#9900CC;">status</span>.<span style="color:#9900CC;">to_s</span>.<span style="color:#9900CC;">strip</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  ticket.<span style="color:#9900CC;">assigned_user_id</span> = users<span style="color:#006600; font-weight:bold;">&#91;</span>i.<span style="color:#9900CC;">assign_to</span>.<span style="color:#9900CC;">to_s</span>.<span style="color:#9900CC;">strip</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  ticket.<span style="color:#9900CC;">milestone_id</span> = milestones<span style="color:#006600; font-weight:bold;">&#91;</span>i.<span style="color:#9900CC;">fix_version</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  ticket.<span style="color:#9900CC;">tags</span></pre></div></div>
</p>



	<p>There was another step.  I ran the first part of the script a couple times to tell me what the different issue_types, statuses, assigned users, fix versions, etc were that my <span class="caps">JIRA</span> data was using.  I then found or created the appropriate data in Lighthouse and added some hashes to translate for me.</p>

	<p>All in all, I&#8217;m pretty thrilled with how easy this was.</p>
 ]]></content:encoded>
			<wfw:commentRss>http://onemanswalk.com/work/2008/04/23/cruise-control-rb-is-moving-to-lighthouse/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using Markaby w/ Rails 2.0.1</title>
		<link>http://onemanswalk.com/work/2007/12/13/using-markaby-w-rails-2-0-1/</link>
		<comments>http://onemanswalk.com/work/2007/12/13/using-markaby-w-rails-2-0-1/#comments</comments>
		<pubDate>Thu, 13 Dec 2007 19:07:00 +0000</pubDate>
		<dc:creator>jeremy</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[	Rails 2.0.1 is out, in general, it&#8217;s pretty nice.  Markaby doesn&#8217;t play too nice w/ it.  Markaby requires every named route to have a .to_s on the end of it.  Yuck.

	After migrating my 3rd project to rails 2.0.1, I got sick of adding .to_s to each named routes, and did some digging.

	Apparently, [...]]]></description>
			<content:encoded><![CDATA[	<p>Rails 2.0.1 is out, in general, it&#8217;s pretty nice.  Markaby doesn&#8217;t play too nice w/ it.  Markaby requires every named route to have a .to_s on the end of it.  Yuck.</p>

	<p>After migrating my 3rd project to rails 2.0.1, I got sick of adding .to_s to each named routes, and did some digging.</p>

	<p>Apparently, somehow a string coming from a named route is not <em>exactly</em> a string.  Sure</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby">  apples_path<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9966CC; font-weight:bold;">class</span> == <span style="color:#CC0066; font-weight:bold;">String</span></pre></div></div>
</p>



	<p>but</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby">  <span style="color:#CC0066; font-weight:bold;">String</span> === apples_path<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>
</p>



	<p>is <span class="caps">NOT</span> true.  I couldn&#8217;t quite track down why this was but it eventually leads to a</p>

<pre>
ActionView::TemplateError (undefined method `string_path' for #) on line #10 of messages/index.mab:

actionpack-2.0.1/lib/action_controller/polymorphic_routes.rb:27:in `send!'
actionpack-2.0.1/lib/action_controller/polymorphic_routes.rb:27:in `polymorphic_url'
actionpack-2.0.1/lib/action_controller/polymorphic_routes.rb:31:in `polymorphic_path'
actionpack-2.0.1/lib/action_view/helpers/url_helper.rb:79:in `url_for'
actionpack-2.0.1/lib/action_view/helpers/url_helper.rb:144:in `link_to'
...
</pre>

	<p>After an hour of trying in vain to find the source of the problem, I found a simple hack that fixes this.  Should have thought of this before, but add this code to your application_helper.rb</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby">  <span style="color:#9966CC; font-weight:bold;">def</span> string_path<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">string</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#CC0066; font-weight:bold;">string</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>
</p>



	<p>If anyone else has a better solution, please pass it over!</p>
 ]]></content:encoded>
			<wfw:commentRss>http://onemanswalk.com/work/2007/12/13/using-markaby-w-rails-2-0-1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Working with iWork and Subversion</title>
		<link>http://onemanswalk.com/work/2007/11/04/working-with-iwork-and-subversion/</link>
		<comments>http://onemanswalk.com/work/2007/11/04/working-with-iwork-and-subversion/#comments</comments>
		<pubDate>Sun, 04 Nov 2007 22:56:00 +0000</pubDate>
		<dc:creator>jeremy</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[	So I&#8217;m a big fan of iWork &#8216;08, pages is nice enough, doesn&#8217;t get in my way, etc.  Numbers is pretty awesome.  It&#8217;s been a while since someone did something revolutionary in the spreadsheet world.  Numbers is it.

	I do have a couple gripes.

	1) if I open a word or excel file, when [...]]]></description>
			<content:encoded><![CDATA[	<p>So I&#8217;m a big fan of iWork &#8216;08, pages is nice enough, doesn&#8217;t get in my way, etc.  Numbers is pretty awesome.  It&#8217;s been a while since someone did something revolutionary in the spreadsheet world.  Numbers is it.</p>

	<p>I do have a couple gripes.</p>

	<p>1) if I open a word or excel file, when I save, it should be saved back to that same word or excel file.  Not all my friends have macs, let alone iWork, why can&#8217;t I save back to the file I opened?  And if I have to do the extra export step, why does iWork forget where the file came from?  Grr.</p>

	<p>2) I am a total excel power user, and numbers is still missing a bunch of features for addins, macros, etc.  It doesn&#8217;t even have applescript support yet as far as I can tell (I&#8217;m sure it will, though, and I am glad they released before they had it)  I&#8217;ve been getting by on a manual export to csv so I can munge data.</p>

	<p>3) and what this blog post is about, is that iWork does not play nice w/ subversion.</p>

	<p>iWork stores it&#8217;s files in &#8220;bundles&#8221; which are actually directories even though they look like files from finder.  When you have stored one of these bundles in subversion, there will be .svn directories inside of it, containing subversion metadata.  The problem comes that every time you save a file in iWork, the entire bundle is replaced w/ the new copy&#8230;and <span class="caps">ALL </span>.svn directories are destroyed.</p>

	<p>This basically renders subversion useless for iWork files.  This is no good, there are some pretty painful <a href="http://www.jpbutler.com/2007/08/29/workaround-for-iwork-and-subversion/" title="">workarounds</a> on the net, and there are a few scripts that turned up, but I wrote my own.</p>

	<p>This script (I call it svn_restore_dirs) will search any subdirectories of the current working directory for files ending in .numbers, .pages, etc.  It will then redownload .svn directories for any of these that are missing theirs.</p>

	<p>Seems to work, and is simple enough.  I wish apple would get their act together.</p>

	<p>Enjoy the script</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'fileutils'</span>
&nbsp;
EXTENSIONS_TO_SEARCH = <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>numbers pages key graffle<span style="color:#006600; font-weight:bold;">&#41;</span>
TMP_DIR = <span style="color:#996600;">&quot;/tmp/missing_svn&quot;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> find_directories_without_svn_dirs
  search_pattern = EXTENSIONS_TO_SEARCH.<span style="color:#9900CC;">map</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>ext<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#996600;">&quot;-name <span style="color:#000099;">\&quot;</span>*.#{ext}<span style="color:#000099;">\&quot;</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot; -or &quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  dirs = <span style="color:#996600;">`find . <span style="color:#000099;">\\</span>( #{search_pattern} <span style="color:#000099;">\\</span>) -type d`</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;<span style="color:#000099;">\n</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  dirs.<span style="color:#9900CC;">reject</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>dir<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exists</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>dir, <span style="color:#996600;">&quot;.svn&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>  
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> get_url_for<span style="color:#006600; font-weight:bold;">&#40;</span>file<span style="color:#006600; font-weight:bold;">&#41;</span>
  info = <span style="color:#996600;">`svn info &quot;#{file}&quot;`</span>
  <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">&quot;can't parse #{info}&quot;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> info =~ <span style="color:#006600; font-weight:bold;">/</span>URL\: <span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#9900CC;">*</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">/</span>
  <span style="color:#0000FF; font-weight:bold;">return</span> $<span style="color:#006666;">1</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> copy_svn_dirs<span style="color:#006600; font-weight:bold;">&#40;</span>from, to<span style="color:#006600; font-weight:bold;">&#41;</span>
  to = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">expand_path</span><span style="color:#006600; font-weight:bold;">&#40;</span>to<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">chdir</span> from <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#CC00FF; font-weight:bold;">Dir</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;**/.svn&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>svn_dir<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#CC00FF; font-weight:bold;">FileUtils</span>.<span style="color:#9900CC;">mv</span> svn_dir, <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>to, svn_dir<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
find_directories_without_svn_dirs.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>dir<span style="color:#006600; font-weight:bold;">|</span>
  url = get_url_for<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span>dir<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;replacing svn dirs for #{dir} from #{url}/#{File.basename(dir)}&quot;</span>
&nbsp;
  <span style="color:#CC00FF; font-weight:bold;">FileUtils</span>.<span style="color:#9900CC;">rm_rf</span><span style="color:#006600; font-weight:bold;">&#40;</span>TMP_DIR<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exists</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>TMP_DIR<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#996600;">`svn co &quot;#{url}/#{File.basename(dir)}&quot; #{TMP_DIR}`</span>
&nbsp;
  copy_svn_dirs<span style="color:#006600; font-weight:bold;">&#40;</span>TMP_DIR, dir<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> $? == <span style="color:#006666;">0</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>
</p>





 ]]></content:encoded>
			<wfw:commentRss>http://onemanswalk.com/work/2007/11/04/working-with-iwork-and-subversion/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Pretty Printing Seconds in Ruby</title>
		<link>http://onemanswalk.com/work/2007/10/16/pretty-printing-seconds-in-ruby/</link>
		<comments>http://onemanswalk.com/work/2007/10/16/pretty-printing-seconds-in-ruby/#comments</comments>
		<pubDate>Tue, 16 Oct 2007 05:28:00 +0000</pubDate>
		<dc:creator>jeremy</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[	I must have written various versions of this code 20 times so far in my career, but never so quickly and cleanly.  I love ruby.

	
    min, sec = sec / 60, sec % 60
    hour, min = min / 60, min % 60
    day, hour [...]]]></description>
			<content:encoded><![CDATA[	<p>I must have written various versions of this code 20 times so far in my career, but never so quickly and cleanly.  I love ruby.</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby">    min, sec = sec <span style="color:#006600; font-weight:bold;">/</span> <span style="color:#006666;">60</span>, sec <span style="color:#006600; font-weight:bold;">%</span> <span style="color:#006666;">60</span>
    hour, min = min <span style="color:#006600; font-weight:bold;">/</span> <span style="color:#006666;">60</span>, min <span style="color:#006600; font-weight:bold;">%</span> <span style="color:#006666;">60</span>
    day, hour = hour <span style="color:#006600; font-weight:bold;">/</span> <span style="color:#006666;">24</span>, hour <span style="color:#006600; font-weight:bold;">%</span> <span style="color:#006666;">24</span>
    week, day = day <span style="color:#006600; font-weight:bold;">/</span> <span style="color:#006666;">7</span>, day <span style="color:#006600; font-weight:bold;">%</span> <span style="color:#006666;">7</span>
&nbsp;
    <span style="color:#006600; font-weight:bold;">&#91;</span>
      week <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span> ? <span style="color:#996600;">&quot;#{week} weeks&quot;</span> : <span style="color:#0000FF; font-weight:bold;">nil</span>,
      day <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span> ? <span style="color:#996600;">&quot;#{day} days&quot;</span> : <span style="color:#0000FF; font-weight:bold;">nil</span>,
      hour <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span> ? <span style="color:#996600;">&quot;#{hour} hours&quot;</span> : <span style="color:#0000FF; font-weight:bold;">nil</span>,
      min <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span> ? <span style="color:#996600;">&quot;#{min} minutes&quot;</span> : <span style="color:#0000FF; font-weight:bold;">nil</span>,
      sec <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span> ? <span style="color:#996600;">&quot;#{sec} seconds&quot;</span> : <span style="color:#0000FF; font-weight:bold;">nil</span>
    <span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">compact</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;, &quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>
</p>



	<p>The really cool thing is the multiple assignment that ruby lets you do.  I haven&#8217;t used it for something exactly like this before, but I do use it often and it&#8217;s really nice.</p>

	<p>I feel like there should be a better way to do the bottom half of this, but this is pretty damn readable, I think.  You might have to have a little rubyFU to remember what compact does &#8211; which is get rid of the nils.</p>

	<p>Anyway, this was about 15 minutes of work (and I did it test first).</p>
 ]]></content:encoded>
			<wfw:commentRss>http://onemanswalk.com/work/2007/10/16/pretty-printing-seconds-in-ruby/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
