<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>lifecoding.com Blog &#187; Ruby</title>
	<atom:link href="http://lifecoding.com/blog/index.php/category/languages/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://lifecoding.com/blog</link>
	<description>(define (life-coding life code) (organize life (using code)))</description>
	<lastBuildDate>Wed, 11 Jun 2008 03:29:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>RailsconfEurope 2007</title>
		<link>http://lifecoding.com/blog/2007/10/18/railsconfeurope-2007/</link>
		<comments>http://lifecoding.com/blog/2007/10/18/railsconfeurope-2007/#comments</comments>
		<pubDate>Thu, 18 Oct 2007 19:57:51 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=34</guid>
		<description><![CDATA[I&#8217;m a little late in mentioning this, but I recently spoke at RailsconfEurope about Rails Refactoring. It was a tutorial talk, and I thought that it went very well. I think the presentation is up on O&#8217;Reilly somewhere; I&#8217;ll link if I can find it.
Overall, the conference was really good. Berlin is an amazing city [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a little late in mentioning this, but I recently spoke at <a href="http://www.railsconfeurope.com/">RailsconfEurope</a> about <a href="http://www.railsconfeurope.com/cs/railseurope2007/view/e_sess/14232">Rails Refactoring</a>. It was a tutorial talk, and I thought that it went very well. I think the presentation is up on O&#8217;Reilly somewhere; I&#8217;ll link if I can find it.</p>
<p>Overall, the conference was really good. Berlin is an amazing city and the majority of the talks were really good. Of special note were the ones by <a href="http://drnicwilliams.com/">Dr. Nic</a>, <a href="http://nubyonrails.com/">Topfunky</a>, and <a href=http://blog.fallingsnow.net/">Evan Phoenix</a>. Their talks about ruby magic, css generation, and rubinius were really well done.</p>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2007/10/18/railsconfeurope-2007/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GoRuCo</title>
		<link>http://lifecoding.com/blog/2007/03/07/goruco/</link>
		<comments>http://lifecoding.com/blog/2007/03/07/goruco/#comments</comments>
		<pubDate>Thu, 08 Mar 2007 03:18:53 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[nyc.rb]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=33</guid>
		<description><![CDATA[The speaker list has been announced for Gotham Ruby Conference (GoRuCo), and I&#8217;m happy to inform you that I&#8217;m one of the speakers. I&#8217;ll be filling your brains with all sorts of information related to context, mocks, and stubs. The rest of the lineup is very strong; this looks like it will be an awesome [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.goruco.com/speakers/">speaker list</a> has been announced for Gotham Ruby Conference (GoRuCo), and I&#8217;m happy to inform you that I&#8217;m one of the speakers. I&#8217;ll be filling your brains with all sorts of information related to context, mocks, and stubs. The rest of the lineup is very strong; this looks like it will be an awesome conference.</p>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2007/03/07/goruco/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nyc.rb turns 3!</title>
		<link>http://lifecoding.com/blog/2007/02/20/nycrb-turns-3/</link>
		<comments>http://lifecoding.com/blog/2007/02/20/nycrb-turns-3/#comments</comments>
		<pubDate>Tue, 20 Feb 2007 19:54:27 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[nyc.rb]]></category>
		<category><![CDATA[refactoring]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=32</guid>
		<description><![CDATA[Well, last Tuesday nyc.rb turned three years old. Of course, we were not content with just turning three, so we decided to start taping our presentations also (By we, I mean me, because I have a video camera and turned it on). Francis gave a testing clinic, while yours truly gave a talk on refactoring. [...]]]></description>
			<content:encoded><![CDATA[<p>Well, last Tuesday nyc.rb turned three years old. Of course, we were not content with just turning three, so we decided to start taping our presentations also (By we, I mean me, because I have a video camera and turned it on). Francis gave a testing clinic, while yours truly gave a talk on refactoring. Both talks are available on Motionbox (the Rails video site at which I work) at <a href="http://www.motionbox.com/playlist/show/4a9fddb51f1cc4">this playlist</a>.</p>
<p>To make things easier for you, I&#8217;ve also embeded the videos after the jump. Francis&#8217;s video is first with mine second. Sorry for the occasional fuzzy video quality, I&#8217;m still not good at filming presentations.</p>
<p><span id="more-32"></span><br />
<embed src="http://www.motionbox.com/external/player/id%3D4a97d7b31e19c4" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" width="425" height="460"></embed></p>
<p></p>
<p><embed src="http://www.motionbox.com/external/player/id%3D4a97dabe1d1ac4" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" width="425" height="460"></embed></p>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2007/02/20/nycrb-turns-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CRUD Presentation</title>
		<link>http://lifecoding.com/blog/2006/07/25/crud-presentation/</link>
		<comments>http://lifecoding.com/blog/2006/07/25/crud-presentation/#comments</comments>
		<pubDate>Wed, 26 Jul 2006 03:32:48 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[CRUD]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=31</guid>
		<description><![CDATA[The slides from my CRUD Presentation to nyc.rb are now up. Lee Nussbaum snagged the audio, so I&#8217;ll sync that up over the next few days and post that too.  If you&#8217;ve seen DHH&#8217;s presentation, this one is pretty much the same thing. In fact, many of the slides look fairly similar. I hope [...]]]></description>
			<content:encoded><![CDATA[<p>The slides from my <a href="http://lifecoding.com/presentations/CRUD_presentation.pdf">CRUD Presentation</a> to <a href="http://nycruby.com">nyc.rb</a> are now up. Lee Nussbaum snagged the audio, so I&#8217;ll sync that up over the next few days and post that too.  If you&#8217;ve seen DHH&#8217;s presentation, this one is pretty much the same thing. In fact, many of the slides look fairly similar. I hope you don&#8217;t mind, DHH :-).</p>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2006/07/25/crud-presentation/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Use Session Sparingly (or The Benefits of Flash)</title>
		<link>http://lifecoding.com/blog/2006/06/05/use-session-sparingly-or-the-benefits-of-flash/</link>
		<comments>http://lifecoding.com/blog/2006/06/05/use-session-sparingly-or-the-benefits-of-flash/#comments</comments>
		<pubDate>Mon, 05 Jun 2006 14:52:37 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=26</guid>
		<description><![CDATA[As tempting as it is to use it for everything, the rails session should be used sparingly.  In reading through the code for my current project, I noticed that we are using the session for storing return urls and query strings when doing login redirects.  This is bad.

Let&#8217;s look at an example of [...]]]></description>
			<content:encoded><![CDATA[<p>As tempting as it is to use it for everything, the rails session should be used sparingly.  In reading through the code for my current project, I noticed that we are using the session for storing return urls and query strings when doing login redirects.  This is <strong>bad</strong>.</p>
<p><span id="more-26"></span></p>
<p>Let&#8217;s look at an example of user behavior to see why:</p>
<ol>
<li>The user types http://superapp.com/account/logged_in into their browser.</li>
<li>This url is protected to the user is redirected to http://superapp.com/account/login and /account/logged_in is stored in session[:jump_to].</li>
<li>The user gets confused, lost, or just behaves like a typical user and navigates somewhere else.</li>
<li>Sometime later, the user goes to http://superapp.com/account/login and logs in.</li>
<li>The user is taken to &#8216;/account/logged_in&#8217; instead of &#8216;account/welcome&#8217;.  The user is confused.</li>
</ol>
<p>Though user confusion on its own is bad, this still may not seem like much of a problem.  So the user gets redirected to a different url than usual, how bad is that?  In the app I&#8217;m currently working on, this behavior can be very bad. Depending on how the user is coming to the site and logging in, a bad return url can cause significant confusion to the user.</p>
<p>To fix this problem, the flash should be used instead of the session.  Though the flash technically is the session, it is automatically cleared after each request.  This prevents time sensitive data such as redirection urls from being stored longer than necessary and guarantees that you do not confuse your user with seemingly different points of entry on login.</p>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2006/06/05/use-session-sparingly-or-the-benefits-of-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby Reminder: Array Subtraction</title>
		<link>http://lifecoding.com/blog/2006/06/05/ruby-reminder-array-subtraction/</link>
		<comments>http://lifecoding.com/blog/2006/06/05/ruby-reminder-array-subtraction/#comments</comments>
		<pubDate>Mon, 05 Jun 2006 14:46:52 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=27</guid>
		<description><![CDATA[Just a reminder when working with arrays of objects generated with Active Record.

[Model.find(1), Model.find(2), Model.find(3)] -
  [Model.find(1)] != [Model.find(2), Model.find(3)]

This does not behave as you would expect, because array subtraction compares elements on their object ids. Each find generates a new object, with a new id, so subtraction does not work. To get the [...]]]></description>
			<content:encoded><![CDATA[<p>Just a reminder when working with arrays of objects generated with Active Record.</p>
<pre>
[Model.find(1), Model.find(2), Model.find(3)] -
  [Model.find(1)] != [Model.find(2), Model.find(3)]
</pre>
<p>This does not behave as you would expect, because array subtraction compares elements on their object ids. Each find generates a new object, with a new id, so subtraction does not work. To get the behavior desired, do this instead:</p>
<pre>
to_be_removed = [Model.find(1)].map{|m| m.id}
[Model.find(1), Model.find(2), Model.find(3)].
  delete_if{|m| to_be_removed.include?(m.id)}
</pre>
<p>It&#8217;s not as beautiful, but it gets the job done.</p>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2006/06/05/ruby-reminder-array-subtraction/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby Makes It Easy</title>
		<link>http://lifecoding.com/blog/2006/03/03/ruby-makes-it-easy/</link>
		<comments>http://lifecoding.com/blog/2006/03/03/ruby-makes-it-easy/#comments</comments>
		<pubDate>Fri, 03 Mar 2006 16:56:05 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=23</guid>
		<description><![CDATA[Oh ruby, you make my job so simple.  I need a class method you&#8217;re lacking, and you just let me add it to you.

class Array
  def map_with_index(procedure=null)
    result = []
    if block_given?
      each_with_index {&#124;item, i&#124; result[i] = yield(item, i) }
   [...]]]></description>
			<content:encoded><![CDATA[<p>Oh ruby, you make my job so simple.  I need a class method you&#8217;re lacking, and you just let me add it to you.</p>
<pre>
class Array
  def map_with_index(procedure=null)
    result = []
    if block_given?
      each_with_index {|item, i| result[i] = yield(item, i) }
    elsif procedure
      each_with_index {|item, i| result[i] = procedure.call(item, i) }
    else
      result = self
    end
    return result
  end
  alias :collect_with_index :map_with_index
end

[1, 2, 3, 4].map_with_index {|elem, i| elem + i } => [1, 3, 5, 7]
</pre>
<p>See how easy that was?</p>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2006/03/03/ruby-makes-it-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nyc.rb In The House!</title>
		<link>http://lifecoding.com/blog/2006/03/01/nycrb-in-the-house/</link>
		<comments>http://lifecoding.com/blog/2006/03/01/nycrb-in-the-house/#comments</comments>
		<pubDate>Wed, 01 Mar 2006 15:40:37 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Higher Order Procedures]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=22</guid>
		<description><![CDATA[Last night&#8217;s meeting was a smashing success.  We had our largest turnout ever with what I think was 28 people.  My presentation went very well, with only a few minor corrections coming from the illustrious David Black.  For those of you following along via the web, I&#8217;ve updated the copy of the [...]]]></description>
			<content:encoded><![CDATA[<p>Last night&#8217;s meeting was a smashing success.  We had our largest turnout ever with what I think was 28 people.  My presentation went very well, with only a few minor corrections coming from the illustrious David Black.  For those of you following along via the web, I&#8217;ve updated the copy of the presentation available <a href="http://lifecoding.com/presentations/s5-higher-order-procedures.html">here</a> to reflect those corrections.  Moving past my accomplishments, <a href="http://www.zedshaw.com">Zed Shaw</a> gave a highly informative presentation on the use of statistics to gauge performance.  Also, <a href="http://stonecode.org/blog">Greg Brown</a> talked about his reporting library Ruport, which looks very interesting.  Needless to say, the meeting was amazing, and I hope to see you at the next one.</p>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2006/03/01/nycrb-in-the-house/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting to Done</title>
		<link>http://lifecoding.com/blog/2006/02/28/getting-to-done/</link>
		<comments>http://lifecoding.com/blog/2006/02/28/getting-to-done/#comments</comments>
		<pubDate>Tue, 28 Feb 2006 19:57:52 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Higher Order Procedures]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=21</guid>
		<description><![CDATA[Tonight&#8217;s presentation on higher order procedures is now listed on the Presentations page to your right.  I&#8217;ll be adding some practice exercises later, but feel free to check out what I have already.
]]></description>
			<content:encoded><![CDATA[<p>Tonight&#8217;s presentation on higher order procedures is now listed on the Presentations page to your right.  I&#8217;ll be adding some practice exercises later, but feel free to check out what I have already.</p>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2006/02/28/getting-to-done/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objects from Scratch</title>
		<link>http://lifecoding.com/blog/2006/02/28/objects-from-scratch/</link>
		<comments>http://lifecoding.com/blog/2006/02/28/objects-from-scratch/#comments</comments>
		<pubDate>Tue, 28 Feb 2006 12:20:22 +0000</pubDate>
		<dc:creator>Trotter Cashion</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Higher Order Procedures]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://lifecoding.com/blog/?p=19</guid>
		<description><![CDATA[Look ma, I made my own object! It doesn&#8217;t handle state that well, but at least it can be passed messages and told to do things.

def make_number(x)
  lambda do &#124;op, *y&#124;
    if op == '+'
      make_number(x + y[0])
    elsif op == '-'
  [...]]]></description>
			<content:encoded><![CDATA[<p>Look ma, I made my own object! It doesn&#8217;t handle state that well, but at least it can be passed messages and told to do things.</p>
<pre>
def make_number(x)
  lambda do |op, *y|
    if op == '+'
      make_number(x + y[0])
    elsif op == '-'
      make_number(x - y[0])
    elsif op == 'val'
      x
    end
  end
end

my_num = make_number(5)         => <#Proc>
my_num.call('+', 7).call('val') => 12
</pre>
<p>In case you can&#8217;t tell, this object creation makes use of higher order procedures. The make number procedure returns the anonymous procedure created by lambda. This form of object creation is not terribly practical, but it sure is cool.</p>
]]></content:encoded>
			<wfw:commentRss>http://lifecoding.com/blog/2006/02/28/objects-from-scratch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

