<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>JT Hopple - Home</title>
  <id>tag:jthopple.com,2008:mephisto/</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  <link href="http://jthopple.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://jthopple.com/" rel="alternate" type="text/html"/>
  <updated>2008-06-25T18:08:18Z</updated>
  <entry xml:base="http://jthopple.com/">
    <author>
      <name>Jeremy</name>
    </author>
    <id>tag:jthopple.com,2008-06-25:34</id>
    <published>2008-06-25T17:48:00Z</published>
    <updated>2008-06-25T18:08:18Z</updated>
    <category term="Programming"/>
    <category term="Ruby"/>
    <category term="Tips"/>
    <link href="http://jthopple.com/2008/6/25/mysql-ruby-thread-blocking" rel="alternate" type="text/html"/>
    <title>Mysql/Ruby Thread Blocking</title>
<summary type="html">&lt;p&gt;It appears that the Mysql/Ruby library blocks all threads for the current process when executing a query.  If you are running a multi-process web application this is not an issue, but for a multi-threaded application that has long-running queries this can be problematic.&lt;/p&gt;

&lt;p&gt;I have a simple reporting service written with the &lt;a href=&quot;http://merbivore.org&quot;&gt;Merb&lt;/a&gt; framework.  In Merb you can make it handle multiple requests at once by setting use_mutex to false in the config/merb.yml file.  This works great until you have a long running mysql query and it forcefully blocks ALL threads in the process.  During this query your Merb app, which you thought was multi-threaded, is no longer multi-threaded.&lt;/p&gt;</summary>  </entry>
  <entry xml:base="http://jthopple.com/">
    <author>
      <name>Jeremy</name>
    </author>
    <id>tag:jthopple.com,2008-06-11:31</id>
    <published>2008-06-11T20:36:00Z</published>
    <updated>2008-06-11T20:39:29Z</updated>
    <category term="Play"/>
    <link href="http://jthopple.com/2008/6/11/comedy" rel="alternate" type="text/html"/>
    <title>Comedy</title>
<summary type="html">&lt;p&gt;One of my computer science professors at Depauw, Dave Berque, has been a closet comedian for years.  He finally stepped up on a real stage.  &lt;a href=&quot;http://www.youtube.com/watch?v=pI_JiaehFN8&quot;&gt;Check it out&lt;/a&gt;.  It definitely made me laugh!&lt;/p&gt;</summary>  </entry>
  <entry xml:base="http://jthopple.com/">
    <author>
      <name>Jeremy</name>
    </author>
    <id>tag:jthopple.com,2008-06-11:30</id>
    <published>2008-06-11T20:26:00Z</published>
    <updated>2008-06-11T20:41:53Z</updated>
    <category term="Rails"/>
    <category term="Tips"/>
    <link href="http://jthopple.com/2008/6/11/passenger-enterprise-ruby" rel="alternate" type="text/html"/>
    <title>Passenger / Enterprise Ruby</title>
<summary type="html">&lt;p&gt;I &lt;strong&gt;finally&lt;/strong&gt; tried out &lt;a href=&quot;http://modrails.com&quot;&gt;Passenger&lt;/a&gt; (mod_rails) and &lt;a href=&quot;http://www.rubyenterpriseedition.com&quot;&gt;Ruby Enterprise Edition&lt;/a&gt;.  Two words come to mind: easy and awesome!&lt;/p&gt;

&lt;p&gt;For those of you that don't know, Passenger is an apache module that makes Ruby on Rails deployment super easy in the same way that deploying php can be super easy.  You simply &lt;a href=&quot;http://modrails.com/documentation/Users%20guide.html#_configuring_passenger&quot;&gt;point apache at the public directory of your Rails application&lt;/a&gt; and you're good to go. Ruby Enterprise Edition is written by the same folks as Passenger and it &lt;a href=&quot;http://www.rubyenterpriseedition.com/faq.html#what_is_this&quot;&gt;improves Ruby's garbage collector and memory allocator&lt;/a&gt;.  They claim that with Ruby Enterprise Edition your Rails apps will use 33% less memory.&lt;/p&gt;

&lt;p&gt;I highly recommend checking it out.&lt;/p&gt;</summary>  </entry>
  <entry xml:base="http://jthopple.com/">
    <author>
      <name>Jeremy</name>
    </author>
    <id>tag:jthopple.com,2008-06-10:29</id>
    <published>2008-06-10T20:37:00Z</published>
    <updated>2008-06-10T21:42:47Z</updated>
    <category term="Programming"/>
    <link href="http://jthopple.com/2008/6/10/programmer-batting-order" rel="alternate" type="text/html"/>
    <title>Programmer Batting Order</title>
<summary type="html">&lt;p&gt;A programmer that I work with did something today that got me thinking about a twist on pair programming.  He swept through the application we are working on and cleaned up some little things that have irked him lately.  It's clear there are benefits in being a &quot;cleanup&quot; programmer once in a while, but are there benefits to being a &quot;leadoff&quot; programmer?  What if we paired up on each task, but not at the same computer and instead in complementary roles -- a leadoff programmer and a cleanup programmer.&lt;/p&gt;

&lt;p&gt;The way I see it, the main benefit of pair programming is having two sets of eyeballs on any given piece of code.  I've tried pair programming in the past with varying levels of success.  There's no doubt that the resulting code is of a higher quality, but it's been my experience that most people have different styles of getting stuff done; and trying to get stuff done at the same computer with another person can be tiring and frustrating. So let's pair up on tasks, but in a specific batting order rather than at the same terminal.&lt;/p&gt;

&lt;p&gt;In a &lt;a href=&quot;http://en.wikipedia.org/wiki/Batting_order_(baseball)&quot;&gt;baseball batting order&lt;/a&gt; there are 9 positions.  The first position is called the &quot;leadoff,&quot; the fourth is the &quot;cleanup hitter,&quot; and the ninth is the &quot;last.&quot;  In the spirit of pair programming I'm going to skip all but the first and fourth. Here's a brief description:&lt;/p&gt;

&lt;ol&gt;&lt;li&gt;The &quot;leadoff&quot; batter is usually the fastest base-runner.  He bats more often than anyone else and needs to have a high on base percentage so that he can score when the power hitters are up&lt;/li&gt;&lt;li&gt;The &quot;cleanup&quot; hitter (the fourth position in baseball) is usually a highly talented hitter whose job is to &quot;clean&quot; the bases by driving home the base-runners to score runs.&lt;/li&gt;&lt;/ol&gt;

&lt;p&gt;These two roles could work really well for programming.  Put a programmer in the leadoff role that is a fast coder.  A person that can whip through a task and get it to a functionally complete state.  Then, put someone in the cleanup position that can review the task, tighten up the code, and push it out to production.  Might work well.  You get two sets of eyeballs on the code and the programmers can work in their own way focusing on their role for each task.&lt;/p&gt;

&lt;p&gt;I think it would be very beneficial and refreshing to swap roles on different tasks, but I wonder if different programmers would ultimately settle into one position or another.  On a given team, I would guess the lineup would become fairly stable after a while.&lt;/p&gt;

&lt;p&gt;With a team of more than two programmers, what if you set an order for a given set of tasks and rotated through the line-up for each task?  Let's say you had a team of 3 programmers.  On the first task, the first batter would be the leadoff and the second the cleanup.  On the second task, the third programmer would leadoff and the first would cleanup, and so on...  It might be interesting.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;A programmer that I work with did something today that got me thinking about a twist on pair programming.  He swept through the application we are working on and cleaned up some little things that have irked him lately.  It's clear there are benefits in being a &quot;cleanup&quot; programmer once in a while, but are there benefits to being a &quot;leadoff&quot; programmer?  What if we paired up on each task, but not at the same computer and instead in complementary roles -- a leadoff programmer and a cleanup programmer.&lt;/p&gt;

&lt;p&gt;The way I see it, the main benefit of pair programming is having two sets of eyeballs on any given piece of code.  I've tried pair programming in the past with varying levels of success.  There's no doubt that the resulting code is of a higher quality, but it's been my experience that most people have different styles of getting stuff done; and trying to get stuff done at the same computer with another person can be tiring and frustrating. So let's pair up on tasks, but in a specific batting order rather than at the same terminal.&lt;/p&gt;

&lt;p&gt;In a &lt;a href=&quot;http://en.wikipedia.org/wiki/Batting_order_(baseball)&quot;&gt;baseball batting order&lt;/a&gt; there are 9 positions.  The first position is called the &quot;leadoff,&quot; the fourth is the &quot;cleanup hitter,&quot; and the ninth is the &quot;last.&quot;  In the spirit of pair programming I'm going to skip all but the first and fourth. Here's a brief description:&lt;/p&gt;

&lt;ol&gt;&lt;li&gt;The &quot;leadoff&quot; batter is usually the fastest base-runner.  He bats more often than anyone else and needs to have a high on base percentage so that he can score when the power hitters are up&lt;/li&gt;&lt;li&gt;The &quot;cleanup&quot; hitter (the fourth position in baseball) is usually a highly talented hitter whose job is to &quot;clean&quot; the bases by driving home the base-runners to score runs.&lt;/li&gt;&lt;/ol&gt;

&lt;p&gt;These two roles could work really well for programming.  Put a programmer in the leadoff role that is a fast coder.  A person that can whip through a task and get it to a functionally complete state.  Then, put someone in the cleanup position that can review the task, tighten up the code, and push it out to production.  Might work well.  You get two sets of eyeballs on the code and the programmers can work in their own way focusing on their role for each task.&lt;/p&gt;

&lt;p&gt;I think it would be very beneficial and refreshing to swap roles on different tasks, but I wonder if different programmers would ultimately settle into one position or another.  On a given team, I would guess the lineup would become fairly stable after a while.&lt;/p&gt;

&lt;p&gt;With a team of more than two programmers, what if you set an order for a given set of tasks and rotated through the line-up for each task?  Let's say you had a team of 3 programmers.  On the first task, the first batter would be the leadoff and the second the cleanup.  On the second task, the third programmer would leadoff and the first would cleanup, and so on...  It might be interesting.&lt;/p&gt;
&lt;p&gt;What do you think?&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://jthopple.com/">
    <author>
      <name>Jeremy</name>
    </author>
    <id>tag:jthopple.com,2007-07-17:20</id>
    <published>2007-07-17T23:03:00Z</published>
    <updated>2007-07-18T14:54:55Z</updated>
    <category term="Mac"/>
    <category term="Tips"/>
    <link href="http://jthopple.com/2007/7/17/easy-mac-cleaning" rel="alternate" type="text/html"/>
    <title>Easy Mac Cleaning</title>
<summary type="html">&lt;p&gt;
Like everything else, computers get messy!  Even Macs.  However, it turns out there are 3 little scripts hiding in your Mac that are intended to periodically clean your system.  The problem is if you use a laptop they probably never get run.  They're scheduled to run in the middle of the night and laptops are rarely left on overnight.
&lt;/p&gt;
&lt;p&gt;
Whenever my Mac seems like it's getting a little sluggish I run these scripts.  It may all be in my head, but I feel like the system is a bit more responsive after having run them.  Here's how:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Open a terminal (for those of you that don't spend your days in a terminal like I do, open Finder, go to Applications &gt; Utilities, and double-click Terminal)&lt;/li&gt;
  &lt;li&gt;Type: &lt;pre class=&quot;console&quot;&gt;sudo periodic daily&lt;/pre&gt; and hit return (it will ask you to enter your password).&lt;/li&gt;
  &lt;li&gt;Type: &lt;pre class=&quot;console&quot;&gt;sudo periodic weekly&lt;/pre&gt; and hit return (this one might take a few minutes).&lt;/li&gt;
  &lt;li&gt;Type: &lt;pre class=&quot;console&quot;&gt;sudo periodic monthly&lt;/pre&gt; and hit return.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;It's that easy!  If you're interested, read more for quick descriptions of what they do.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;
Like everything else, computers get messy!  Even Macs.  However, it turns out there are 3 little scripts hiding in your Mac that are intended to periodically clean your system.  The problem is if you use a laptop they probably never get run.  They're scheduled to run in the middle of the night and laptops are rarely left on overnight.
&lt;/p&gt;
&lt;p&gt;
Whenever my Mac seems like it's getting a little sluggish I run these scripts.  It may all be in my head, but I feel like the system is a bit more responsive after having run them.  Here's how:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Open a terminal (for those of you that don't spend your days in a terminal like I do, open Finder, go to Applications &gt; Utilities, and double-click Terminal)&lt;/li&gt;
  &lt;li&gt;Type: &lt;pre class=&quot;console&quot;&gt;sudo periodic daily&lt;/pre&gt; and hit return (it will ask you to enter your password).&lt;/li&gt;
  &lt;li&gt;Type: &lt;pre class=&quot;console&quot;&gt;sudo periodic weekly&lt;/pre&gt; and hit return (this one might take a few minutes).&lt;/li&gt;
  &lt;li&gt;Type: &lt;pre class=&quot;console&quot;&gt;sudo periodic monthly&lt;/pre&gt; and hit return.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;It's that easy!  If you're interested, read more for quick descriptions of what they do.&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;Daily&lt;/strong&gt;
  &lt;ul&gt;
     &lt;li&gt;Removes long-lived system log files&lt;/li&gt;
     &lt;li&gt;Removes temporary junk files.&lt;/li&gt;
     &lt;li&gt;Removes system messages older than 21 days.&lt;/li&gt;
     &lt;li&gt;Does some account and security auditing&lt;/li&gt;
     &lt;li&gt;Rotates Log files&lt;/li&gt;
     &lt;li&gt;Deletes all system warning and info messages older than a few days.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;Weekly&lt;/strong&gt;
  &lt;ul&gt;
     &lt;li&gt;Rebuilds the &lt;code&gt;&lt;a href=&quot;http://www.oreillynet.com/linux/cmd/cmd.csp?path=l/locate&quot;&gt;locate&lt;/a&gt;&lt;/code&gt; database (this is what causes the weekly task to take a few minutes).&lt;/li&gt;
     &lt;li&gt;Rebuilds the &lt;code&gt;&lt;a href=&quot;http://www.oreillynet.com/linux/cmd/cmd.csp?path=w/whatis&quot;&gt;whatis&lt;/a&gt;&lt;/code&gt; database.&lt;/li&gt;
     &lt;li&gt;Rotates the logs&lt;/li&gt;
  &lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;Monthly&lt;/strong&gt;
  &lt;ul&gt;
     &lt;li&gt;
       Performs login accounting
     &lt;/li&gt;
     &lt;li&gt;Rotates Log files&lt;/li&gt;
  &lt;/ul&gt;
&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://jthopple.com/">
    <author>
      <name>Jeremy</name>
    </author>
    <id>tag:jthopple.com,2007-07-10:19</id>
    <published>2007-07-10T16:35:00Z</published>
    <updated>2007-07-10T16:40:33Z</updated>
    <category term="Design"/>
    <category term="Programming"/>
    <category term="Rails"/>
    <category term="Ruby"/>
    <category term="Tips"/>
    <link href="http://jthopple.com/2007/7/10/list-view-partial-pattern" rel="alternate" type="text/html"/>
    <title>List View Partial Pattern</title>
<summary type="html">&lt;p&gt;Most applications display lists of various things and they usually display these lists in slightly different ways. In my opinion, there isn't a one-size-fits-all solution to building these lists, but there is a pattern that seems to work pretty well. It consists of three parts: the list, the list-item, and the item. In addition to partitioning your lists into smaller pieces that are easier to deal with, it also makes it very easy to add both css styling and ajax behaviors to your lists.
&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;Most applications display lists of various things and they usually display these lists in slightly different ways. In my opinion, there isn't a one-size-fits-all solution to building these lists, but there is a pattern that seems to work pretty well. It consists of three parts: the list, the list-item, and the item. In addition to partitioning your lists into smaller pieces that are easier to deal with, it also makes it very easy to add both css styling and ajax behaviors to your lists.
&lt;/p&gt;
&lt;p&gt;The examples below use Ruby on Rails, but this pattern should work for your language/framework of choice.  Also, I'm not going to show any of the CRUD controller actions since they should all be very simple and are unaffected by this pattern.&lt;/p&gt;

&lt;p&gt;To implement the pattern for, let's say, a people controller, create three partials: _list.rhtml, _list_item.rhtml, and _item.rhtml.
&lt;/p&gt;

&lt;p&gt;_list.rhtml
&lt;samp&gt;
&amp;lt;%= link_to &quot;Add new&quot;, new_person_url %&gt;
&lt;ul class=&quot;list&quot;&gt;
  &amp;lt;%= render :partial =&gt; &quot;people/list_item&quot;, :locals =&gt; { :person =&gt; person } %&gt;
&lt;/ul&gt;
&lt;/samp&gt;
&lt;/p&gt;

&lt;p&gt;_list_item.rhtml
&lt;samp&gt;
&lt;li class=&quot;list_item&quot;&gt;
  &amp;lt;%= render :partial =&gt; &quot;people/item&quot;, :locals =&gt; { :person =&gt; person } %&gt;
  &lt;ul class=&quot;controls&quot;&gt;
    &lt;li&gt;&amp;lt;%= link_to &quot;edit&quot;, edit_person_url(person) %&gt;&lt;/li&gt;
    &lt;li&gt;&amp;lt;%= link_to &quot;delete&quot;, person_url(person), :method =&gt; :delete %&gt;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/li&gt;
&lt;/samp&gt;
&lt;/p&gt;

&lt;p&gt;_item.rhtml
&lt;samp&gt;
&lt;div class=&quot;item&quot;&gt;
  &lt;h2&gt;&amp;lt;%= person.first_name %&gt;&amp;lt;%= person.last_name %&gt;&lt;/h2&gt;
  &lt;div class=&quot;details&quot;&gt;...&lt;/div&gt;
&lt;/div&gt;&lt;/samp&gt;
&lt;/p&gt;

&lt;p&gt;Pretty simple partials, eh?  You may be wondering what the big deal is. There really isn't one, but here's why I like to use this pattern.  First, this pattern partitions your list display into small easy to work with semantical chunks.  If you want to change something in the list you don't have to dig through a ton of code, and by using the suggested ids and class names in the markup you can easily style the list both globally for your application and specifically for a particular list id.
&lt;/p&gt;

&lt;p&gt;Though I recommend always building applications sans-ajax first, this pattern makes it easy to ajax-ify a list without having to refactor the list view. When you want to have your list items fade away when they're deleted, you can simply change the link_to to a link_to_remote (you can do this manually or &lt;a href=&quot;http://www.ujs4rails.com/&quot;&gt;unobtrusively&lt;/a&gt;) and then add a destroy.rjs template to update your page.&lt;/p&gt;

&lt;p&gt;destroy.rjs
&lt;samp&gt;
  page.visual_effect :fade, &quot;Person_#{@person.id}&quot;
&lt;/samp&gt;
&lt;/p&gt;

&lt;p&gt;Now, when you delete your items they'll gently fade from the list.  &lt;/p&gt;

&lt;p&gt;Next, lets say you want to use ajax to create new items.  If you add an inline form to your list view that serializes the form fields and sends them to the server via ajax you can very easily have it respond with a chunk of javascript that inserts the newly rendered person, using the _list_item.rhtml partial, into the existing list.  Ruby on Rails makes this a snap.
&lt;/p&gt;

&lt;p&gt;New person form
&lt;samp&gt;
  &amp;lt;% remote_form_for :person, @person, :url =&gt; person_url do |f| %&gt;
    &lt;p&gt;
      &amp;lt;label for=&quot;person_first_name&quot;&gt;First Name&amp;lt;/label&gt;
      &amp;lt;%= f.text_field :first_name %&gt;
    &lt;/p&gt;
    &lt;p&gt;
      &amp;lt;label for=&quot;person_last_name&quot;&gt;Last Name&amp;lt;/label&gt;
      &amp;lt;%= f.text_field :last_name %&gt;
    &lt;/p&gt;
    &amp;lt;%= submit_tag &quot;Save Person&quot; %&gt;
  &amp;lt;% end %&gt;
&lt;/samp&gt;  
&lt;/p&gt;

&lt;p&gt;Once this form is submitted via ajax, your controller will add the person and then render the create.rjs template in response to the javascript ajax call.
&lt;/p&gt;

&lt;p&gt;create.rjs
&lt;samp&gt;
  page.insert :bottom, &quot;PersonList&quot;, :partial =&gt; &quot;person/list_item&quot;, :locals =&gt; { :person =&gt; @person }
  page.visual_effect :highlight, &quot;Person_#{@person.id}&quot;
&lt;/samp&gt;
&lt;/p&gt;

&lt;p&gt;Again, without having to modify the list partials it was very easy to add an ajax behavior for inserting new items into the list.  I'm not going to go into all of the details, but adding behaviors for updating and sorting items should just as easy as creating and destroying them.&lt;/p&gt;

&lt;p&gt;Without too much extra effort up front, this pattern will help clean up your list views, make them more maintainable, and will make it easier to add css and javascript behaviors to your lists when the time comes.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://jthopple.com/">
    <author>
      <name>Jeremy</name>
    </author>
    <id>tag:jthopple.com,2007-03-29:18</id>
    <published>2007-03-29T16:11:00Z</published>
    <updated>2007-03-29T16:41:31Z</updated>
    <category term="Gotchas"/>
    <category term="Rails"/>
    <category term="Tips"/>
    <link href="http://jthopple.com/2007/3/29/disable_with" rel="alternate" type="text/html"/>
    <title>:disable_with</title>
<content type="html">
            &lt;p&gt;About a week ago I stumbled across an option that you can pass to the &lt;code&gt;submit_tag&lt;/code&gt; form helper in Rails &amp;mdash; &lt;code&gt;:disable_with&lt;/code&gt;.&lt;/p&gt;

&lt;samp&gt;&amp;lt;%= sumbit_tag &quot;Save&quot;, :disable_with =&gt; &quot;Saving...&quot; %&gt;&lt;/samp&gt;

&lt;p&gt;Now (thanks to some automatically injected javascript) when you press this &quot;Save&quot; button it will disable itself, change its text to &quot;Saving...&quot;, and then submit the form.  Cool, right?
&lt;/p&gt;

&lt;p&gt;
Yeah, most of the time it's cool.  It's nice to do anything that gives the user an indication of what's going on &amp;mdash; especially in a way that prevents them from repeatedly pushing a button on a form that takes a second or two longer than it should.
&lt;/p&gt;

&lt;p&gt;
However, there is one time it's not cool!  It's not cool if you have a form that contains more than one submit button and you expect to do different things depending on which button is pushed.  A button is simply an input tag just like any other input tag in a form.  It has a type, &quot;submit&quot; in this case, a name and a value.  The GOTCHA is that, like any other input field, &lt;em&gt;if it's disabled it doesn't get posted&lt;/em&gt; to the server.  Oooops!  So much for using &lt;code&gt;:disable_with&lt;/code&gt; on this particular form!
&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://jthopple.com/">
    <author>
      <name>Jeremy</name>
    </author>
    <id>tag:jthopple.com,2007-03-15:16</id>
    <published>2007-03-15T16:42:00Z</published>
    <updated>2007-03-15T18:14:06Z</updated>
    <category term="Rails"/>
    <category term="Tips"/>
    <link href="http://jthopple.com/2007/3/15/destroying-models" rel="alternate" type="text/html"/>
    <title>Destroying Models</title>
<content type="html">
            &lt;p&gt;
Surely you use the Rails generator script to create your models! You fill in the blanks in the migration for the new model, run the migration, work on the model and its tests, and then commit to Subversion.  Right?  And, surely after you've worked on a project for a while you've needed to remove one of these models.  You write a new migration to remove the table that maps to your &lt;code&gt;stupid_model&lt;/code&gt; and then you...
&lt;/p&gt;

&lt;pre class=&quot;console&quot;&gt;
script/destroy model stupid_model --svn
&lt;/pre&gt;

&lt;p&gt;
Ooops!  See what just happened?
&lt;/p&gt;

&lt;pre class=&quot;console&quot;&gt;
D         db/migrations/002_create_stupid_model.rb
&lt;/pre&gt;

&lt;p&gt;
You conveniently used the &lt;code&gt;--svn&lt;/code&gt; switch to delete the files from subversion and it not-so-conveniently deleted the initial migration for the model.  It may not be obvious at first, but the next time someone tries to &lt;code&gt;rake db:migrate&lt;/code&gt; through your series of migration scripts from start to finish it will fail when it tries to drop a table that never existed in their database (assuming it didn't fail earlier).
&lt;/p&gt;

&lt;p&gt;This morning I needed to remove a model and rather than doing it by hand (to avoid the above problem) I thought I'd take a quick look through the generator source to see if it would be easy to add an option that told the destroy model script to skip the migration.  Turns out it's already there (&lt;code&gt;--skip-migration&lt;/code&gt;) it just isn't documented!!&lt;/p&gt;

&lt;pre class=&quot;console&quot;&gt;
script/destroy model stupid_model --skip-migration --svn
&lt;/pre&gt;

&lt;p&gt;Perfect!  However, it might be nice if this were the default behavior...&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://jthopple.com/">
    <author>
      <name>Jeremy</name>
    </author>
    <id>tag:jthopple.com,2007-03-04:13</id>
    <published>2007-03-04T19:59:00Z</published>
    <updated>2007-03-04T20:49:57Z</updated>
    <category term="Plugins"/>
    <category term="Rails"/>
    <category term="Ruby"/>
    <link href="http://jthopple.com/2007/3/4/monkeycamp" rel="alternate" type="text/html"/>
    <title>Monkeycamp</title>
<content type="html">
            &lt;p&gt;
  I recently started working on a project that needs to integrate with &lt;a href=&quot;http://basecamphq.com&quot;&gt;Basecamp&lt;/a&gt;.  37signals provides a ruby script, &lt;a href=&quot;&quot;&gt;basecamp.rb&lt;/a&gt;, to ease the use of their &lt;a href=&quot;http://basecamphq.com/api&quot;&gt;API&lt;/a&gt;, but it hasn't kept up.  Specifically, they expanded the API to expose the time-tracking functionality in Basecamp.  
&lt;/p&gt;

&lt;p&gt;
Being fond of &lt;a href=&quot;http://chadfowler.com/2006/1/26/the-virtues-of-monkey-patching&quot;&gt;monkey patching&lt;/a&gt; I thought I'd create a Ruby on Rails plugin so I can easily add whatever methods I need without having to alter the actual basecamp.rb file.  I'm sure I'll be adding more methods in the near future, but right now the plugin just contains one method for grabbing time entries.
&lt;/p&gt;

&lt;p&gt;You can grab this plugin from svn:&lt;/p&gt;

&lt;p&gt;
&lt;pre class=&quot;console&quot;&gt;
svn co http://svn.jthopple.com/plugins/monkeycamp
&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;Or, install it directly from the root of a Rails project:&lt;/p&gt;

&lt;p&gt;
&lt;pre class=&quot;console&quot;&gt;
script/plugin install -x http://svn.jthopple.com/plugins/monkeycamp
&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;Check out the &lt;a href=&quot;http://docs.jthopple.com/monkeycamp&quot;&gt;documentation&lt;/a&gt; for more information.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://jthopple.com/">
    <author>
      <name>Jeremy</name>
    </author>
    <id>tag:jthopple.com,2007-03-04:15</id>
    <published>2007-03-04T17:55:00Z</published>
    <updated>2007-03-04T17:57:50Z</updated>
    <category term="Tips"/>
    <link href="http://jthopple.com/2007/3/4/itunes-backup" rel="alternate" type="text/html"/>
    <title>iTunes Backup</title>
<content type="html">
            &lt;p&gt;
I've been looking for an easy way to backup my iTunes library to an exteral hard drive.  Here's a &lt;a href=&quot;http://ctro.net/2007/3/3/backing-up-your-itunes-library&quot;&gt;
simple solution&lt;/a&gt;.
&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://jthopple.com/">
    <author>
      <name>Jeremy</name>
    </author>
    <id>tag:jthopple.com,2007-02-27:11</id>
    <published>2007-02-27T04:15:00Z</published>
    <updated>2008-01-17T20:42:10Z</updated>
    <category term="Outdoors"/>
    <category term="Play"/>
    <link href="http://jthopple.com/2007/2/27/a-good-day" rel="alternate" type="text/html"/>
    <title>A great day...</title>
<content type="html">
            &lt;p&gt;
Some days are good; other days are great! This day started out like most others except that it was snowing really, really hard.  It's actually been snowing quite a bit over the last 3 weeks, but this morning it was dumping. Snow can be a great motivator.  Check out this day...
&lt;/p&gt;


&lt;ul&gt;
 &lt;li&gt;07:15 &amp;mdash; Morning coffee with Barclay.&lt;/li&gt;
 &lt;li&gt;07:30 &amp;mdash; Client work: &lt;a href=&quot;http://www.openmarketwine.com&quot;&gt;Openmarket Wine&lt;/a&gt;&lt;/li&gt; 
 &lt;li&gt;11:30 &amp;mdash; Quick PB&amp;amp;J with Barclay... Or, PB&amp;amp;J with Salt &amp;amp; Vinegar chips smashed in side in her case.&lt;/li&gt;
 &lt;li&gt;12:00 &amp;mdash; Gathered up tax information and dropped it at the accountant's (phew!)&lt;/li&gt;
 &lt;li&gt;14:00 &amp;mdash; More client work using &lt;a href=&quot;http://www.rubyonrails.com&quot;&gt;Ruby on Rails&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;
    15:00 &amp;mdash; Teton Pass  ...and &lt;a href=&quot;http://ctro.net&quot;&gt;Clint's&lt;/a&gt; cell phone camera.
    &lt;br /&gt;&amp;lt;object height=&quot;355&quot; width=&quot;425&quot;&gt;&amp;lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/0gQjTDw4z6M&amp;rel=1&quot;&gt;&amp;lt;/param&gt;&amp;lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt;&amp;lt;/param&gt;&amp;lt;embed type=&quot;application/x-shockwave-flash&quot; src=&quot;http://www.youtube.com/v/0gQjTDw4z6M&amp;rel=1&quot; height=&quot;355&quot; wmode=&quot;transparent&quot; width=&quot;425&quot;&gt;&amp;lt;/embed&gt;&amp;lt;/object&gt;
 &lt;/li&gt;
 &lt;li&gt;18:00 &amp;mdash; Back to work!&lt;/li&gt;
&lt;/ul&gt;
          </content>  </entry>
  <entry xml:base="http://jthopple.com/">
    <author>
      <name>Jeremy</name>
    </author>
    <id>tag:jthopple.com,2007-02-13:10</id>
    <published>2007-02-13T05:27:00Z</published>
    <updated>2007-02-13T10:06:11Z</updated>
    <category term="Outdoors"/>
    <category term="Play"/>
    <category term="Work"/>
    <link href="http://jthopple.com/2007/2/13/pull-my-finger" rel="alternate" type="text/html"/>
    <title>Pull My Finger</title>
<summary type="html">&lt;p&gt;
I just recently finished my first season of &lt;a href=&quot;http://en.wikipedia.org/wiki/Broomball&quot;&gt;broomball&lt;/a&gt; &amp;mdash; what a fun and crazy game!  Running around on an outdoor ice rink in your tennis shoes trying to swat a small ball into a net with a stick resembling a modified broom, playing for a team named &lt;em&gt;Pull My Finger&lt;/em&gt;.
&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;
I just recently finished my first season of &lt;a href=&quot;http://en.wikipedia.org/wiki/Broomball&quot;&gt;broomball&lt;/a&gt; &amp;mdash; what a fun and crazy game!  Running around on an outdoor ice rink in your tennis shoes trying to swat a small ball into a net with a stick resembling a modified broom, playing for a team named &lt;em&gt;Pull My Finger&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
I was hesitant to commit when I was first invited to join the team (and nearly quit after minorly injuring my shoulder during warm-ups before the first game), but I'm glad I did and stuck with it.  It's been a long time since I've played a team sport &amp;mdash; like, since seventh grade little league long &amp;mdash; so it was a bit of an adjustment and kind of stressful at first.  A couple of games, a few beers, and a handful of goals later and I was over my nerves, having fun, and just trying to help the team get the next win . . . or the next loss as it turned out.
&lt;/p&gt;

&lt;p&gt;
The experience got me thinking a bit about teams and team-work.  It seems really hard to get a team to come together and work towards a common goal. But I'm not sure it's the team-building part that's hard.  The hard part is defining the common goal.  With broomball it's easy &amp;mdash; get the ball in your opponent's goal more times than they get it in yours.  In business it's not so easy.  Before you can start building your team you have to invent the game and clearly define the objective.  Figure that out and I think the team might find you.
&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://jthopple.com/">
    <author>
      <name>Jeremy</name>
    </author>
    <id>tag:jthopple.com,2007-02-03:9</id>
    <published>2007-02-03T01:37:00Z</published>
    <updated>2007-02-13T08:17:03Z</updated>
    <category term="Programming"/>
    <category term="Rails"/>
    <category term="Ruby"/>
    <link href="http://jthopple.com/2007/2/3/pass-the-hash" rel="alternate" type="text/html"/>
    <title>Pass the Hash</title>
<summary type="html">&lt;p&gt;
Code readability is an undisputed contributor to increased programmer productivity.  Ruby on Rails shines in this department by effectively using two main pieces of Ruby &amp;mdash; the &lt;a href=&quot;http://corelib.rubyonrails.com/classes/Hash.html&quot;&gt;hash&lt;/a&gt; and the &lt;a href=&quot;http://corelib.rubyonrails.com/classes/Symbol.html&quot;&gt;symbol&lt;/a&gt;.  These two things are used all throughout Rails, but most importantly as method parameters.  There are two keys to keep in mind when writing methods:
&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When passing multiple data parameters to a method, pass a hash&lt;/li&gt;
&lt;li&gt;When telling a method how to behave, pass a symbol&lt;/li&gt;
&lt;/ol&gt;</summary><content type="html">
            &lt;p&gt;
Code readability is an undisputed contributor to increased programmer productivity.  Ruby on Rails shines in this department by effectively using two main pieces of Ruby &amp;mdash; the &lt;a href=&quot;http://corelib.rubyonrails.com/classes/Hash.html&quot;&gt;hash&lt;/a&gt; and the &lt;a href=&quot;http://corelib.rubyonrails.com/classes/Symbol.html&quot;&gt;symbol&lt;/a&gt;.  These two things are used all throughout Rails, but most importantly as method parameters.  There are two keys to keep in mind when writing methods:
&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When passing multiple data parameters to a method, pass a hash&lt;/li&gt;
&lt;li&gt;When telling a method how to behave, pass a symbol&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
From a code readability standpoint, this is huge.  Using the &lt;a href=&quot;http://rails.rubyonrails.com/classes/ActiveRecord/Base.html#M000992&quot;&gt;&lt;code&gt;ActiveRecord::Base.find&lt;/code&gt;&lt;/a&gt; method as an example, what's more readable?
&lt;/p&gt;

&lt;samp&gt;
  Article.find(:all, nil, :tags, &quot;tags.name = 'ruby'&quot;, &quot;articles.created_at DESC&quot;)
&lt;/samp&gt;

&lt;p&gt;or the way it's done in ActiveRecord...&lt;/p&gt;

&lt;samp&gt;
  Article.find(:all, 
      :include =&gt; :tags, 
      :conditions =&gt; &quot;tags.name = 'ruby'&quot;, 
      :order =&gt; &quot;articles.created_at DESC&quot;)
&lt;/samp&gt;

&lt;p&gt;
The second example is more readable.  When reading the second example it's very quick and easy to comprehend exactly what is being passed to the method.  Sure, the first method works and requires less typing, but the only way to know for sure what's being passed is to either have the method's prototype memorized or look it up in the reference.   The other thing to note about the &lt;code&gt;find&lt;/code&gt; method used above is that it takes a symbol as it's first parameter.  This symbol clearly and immediately specifies the desired behavior of the method.
&lt;/p&gt;

&lt;p&gt;
Keep this in mind when writing new methods that accept more than one obvious parameter.  In addition to writing code, programmers need to be able to read code.  This simple habit of passing parameters as a hash or a symbol will increase code readability and improve programmer productivity.
&lt;/p&gt;
          </content>  </entry>
</feed>
