<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Rant first, think later.</title>
    <link>http://nicholaswright.org/blog/</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Rant first, think later.</description>
    <item>
      <title>GTA 4 vs Iron Man</title>
      <description>&lt;p&gt;In the recent months there has been some debate regarding whether or not the release of Grand Theft Auto 4 was going to affect the ticket sales for the Iron Man film during it&amp;#8217;s opening weekend.&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.g4tv.com/xplay/blog/post/684414/Sesslers_Soapbox_Grand_Theft_Box_Office.html"&gt;Adam Sessler&amp;#8217;s take on the issue&lt;/a&gt; is that the companies responsible for the film are simply trying to place blame on &lt;span class="caps"&gt;GTA&lt;/span&gt; in an attempt to anticipate poor success at the box office and that if the movie is good, people will see it regardless.&lt;/p&gt;


	&lt;p&gt;While I agree that people will indeed see the film if they want to see it bad enough, that doesn&amp;#8217;t necessarily mean that a huge chunk of people will not wait beyond opening weekend, or even wait for it to arrive in other forms of distribution before seeing it. I don&amp;#8217;t think that the power of immersion in gaming should not be ignored here. Though I do happen to have little doubt that Iron Man will probably be a pretty terrible film, I do think that it&amp;#8217;s ticket sales will be affected by the release of games such as &lt;span class="caps"&gt;GTA 4&lt;/span&gt;. At least during opening weekend.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ve only owned the game for a few days now, but every chance I get outside of work, I&amp;#8217;m more than likely playing the game. The story is involving enough, and provides such a visceral experience, that I can&amp;#8217;t help but think that most gamers would rather spend the next several weeks playing the game to death.&lt;/p&gt;


	&lt;p&gt;I feel this sort of thing should be a very real concern for the film industry. Gaming has matured to the point where the only barrier between it and the mainstream should be the cost of investment. I&amp;#8217;m also of the opinion that a movie based on a comic book series is trying to reach an audience that will also largely consist of gamers, and is therefore at an extreme disadvantage when going up against a game of &lt;span class="caps"&gt;GTA 4&lt;/span&gt;&amp;#8217;s caliber.&lt;/p&gt;


	&lt;p&gt;It&amp;#8217;s possible I&amp;#8217;m wrong and that most normal people have no trouble taking a few hours to leave their house, go all of the way to the theater, watch their little movie and go all of the way home rather than simply getting the most out of their previous investment first.  Still, I doubt it highly.&lt;/p&gt;


	&lt;p&gt;Sure, gaming isn&amp;#8217;t quite &lt;a href="http://techdirt.com/articles/20080430/003115984.shtml"&gt;&amp;#8220;next generation Hollywood&amp;#8221;&lt;/a&gt;, but there are enough die hard (and even casual) gamers out there that will easily align themselves with gaming when given the option on a saturday night.&lt;/p&gt;


	&lt;p&gt;Only time will tell.&lt;/p&gt;</description>
      <pubDate>Thu,  1 May 2008 17:46:25 CDT</pubDate>
      <guid>http://nicholaswright.org/blog/articles/2008/05/01/gta-4-vs-iron-man</guid>
      <link>http://nicholaswright.org/blog/articles/2008/05/01/gta-4-vs-iron-man</link>
      <category>films</category>
      <category>gaming</category>
      <category>media</category>
      <trackback:ping>http://nicholaswright.org/blog/articles/trackback/42</trackback:ping>
    </item>
    <item>
      <title>A GTA 4 of my very own</title>
      <description>&lt;p&gt;The release of Grand Theft Auto 4 is only a few short days away. Personally I&amp;#8217;m getting extremely antsy.&lt;/p&gt;


	&lt;p&gt;This morning I pre ordered the game from &lt;a href="http://www.bestbuy.com"&gt;Best Buy&lt;/a&gt; for in store pickup and managed to walk away only a mere $5.32 less rich.&lt;/p&gt;


	&lt;p&gt;Product Total:     $59.99&lt;br /&gt;
Reward Certificates     -$55.00&lt;br /&gt;
Tax:     $0.33&lt;br /&gt;
Order Total (charged to credit card):     $5.32&lt;br /&gt;
Not camping out in the cold: Priceless&lt;/p&gt;


	&lt;p&gt;It&amp;#8217;s times like this that I&amp;#8217;m really glad I spend stupid amounts of money at Best Buy. I&amp;#8217;m even more happy that my wife always remembers to use our reward zone number so I can stock pile points for just such an occasion.&lt;/p&gt;


	&lt;p&gt;When I go to pick up my copy from the store I&amp;#8217;m going to use the other few hundred dollars worth of reward zone certificates and I&amp;#8217;m going to load up on all of sorts of useless things. I certainly can&amp;#8217;t wait.&lt;/p&gt;


	&lt;p&gt;Now that I&amp;#8217;ve pre ordered &lt;span class="caps"&gt;GTA 4&lt;/span&gt;, all that&amp;#8217;s left is to sit back and be amazed by how much freedom is afforded to you by the game:&lt;/p&gt;


&lt;object height="350" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/RfiB3SbXZrQ"&gt;&lt;embed src="http://www.youtube.com/v/RfiB3SbXZrQ" type="application/x-shockwave-flash" height="350" width="425"&gt;&lt;/object&gt;

	&lt;p&gt;Simply amazing. Too bad I&amp;#8217;ll have to wait until next year before I can check out some of my trophies in &lt;a href="http://en.wikipedia.org/wiki/Playstation_Home"&gt;Home&lt;/a&gt;...&lt;/p&gt;</description>
      <pubDate>Thu, 24 Apr 2008 16:17:00 CDT</pubDate>
      <guid>http://nicholaswright.org/blog/articles/2008/04/24/a-gta-4-of-my-very-own</guid>
      <link>http://nicholaswright.org/blog/articles/2008/04/24/a-gta-4-of-my-very-own</link>
      <category>gaming</category>
      <category>media</category>
      <category>general</category>
      <category>general</category>
      <trackback:ping>http://nicholaswright.org/blog/articles/trackback/41</trackback:ping>
    </item>
    <item>
      <title>Persisting a user session from RoR-&amp;gt;PHP</title>
      <description>&lt;p&gt;Recently I was given the task of integrating a (complete for all intents and purposes) &lt;span class="caps"&gt;PHP&lt;/span&gt; application with our main Ruby on Rails application. Because the &lt;span class="caps"&gt;PHP&lt;/span&gt; application needed to display a similar interface and required knowledge of the user&amp;#8217;s account, I needed a way to access that data from the database both applications were now sharing. The only real requirement I had was that I absolutely didn&amp;#8217;t want to make the user login to the &lt;span class="caps"&gt;PHP&lt;/span&gt; app if they were already authenticated on the Rails side of things as this seemed unnecessary and interrupted the flow things.&lt;/p&gt;


	&lt;p&gt;I did a bit of searching and, while I did find the &lt;a href="http://wiki.rubyonrails.org/rails/pages/PhpSession"&gt;wiki page on going from &lt;span class="caps"&gt;PHP &lt;/span&gt;-&gt; Rails&lt;/a&gt;, I wasn&amp;#8217;t able to find anything that fit my specific need, so I set out to roll my own. I read an article this morning from somebody &lt;a href="http://work.rowanhick.com/2008/04/10/rails-php-sharing-the-same-session/"&gt;who had ostensibly encountered the same problem as I&lt;/a&gt;, and was able to come up with a much different solution than what I had come up with. Therefore I thought it would be fun to share some of the details of my approach.&lt;/p&gt;


	&lt;p&gt;The first way I thought of doing this was to post the session key across to the &lt;span class="caps"&gt;PHP&lt;/span&gt; app and then just do a lookup in the sessions table. This approach was unwieldy as it required me to expose the session key and it would also mean that users would be forced to enter the &lt;span class="caps"&gt;PHP&lt;/span&gt; portion from our provided links. Direct linking would simply not work. Thankfully I didn&amp;#8217;t have to worry about this since we&amp;#8217;re now using the fancy shmancy new &lt;a href="http://caboo.se/doc/classes/CGI/Session/CookieStore.html"&gt;CookieStore&lt;/a&gt; instead of the previously recommended &lt;a href="http://caboo.se/doc/classes/CGI/Session/ActiveRecordStore.html"&gt;ActiveRecordStore&lt;/a&gt;.&lt;/p&gt;


Now I just had to figure out how to read in the cookies. I took a quick look to see how &lt;a href="http://caboo.se/doc/classes/CGI/Session/CookieStore.html#M004043"&gt;Rails&lt;/a&gt; was &lt;a href="http://caboo.se/doc/classes/CGI/Session/CookieStore.html#M004042"&gt;storing&lt;/a&gt; the data in the cookie:
&lt;pre&gt;
     # File vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb, line 131
131:     def marshal(session)
132:       data = ActiveSupport::Base64.encode64(Marshal.dump(session)).chop
133:       CGI.escape "#{data}--#{generate_digest(data)}" 
134:     end
&lt;/pre&gt;

&lt;pre&gt;
    # File vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb, line 124
124:   def generate_digest(data)
125:     key = @secret.respond_to?(:call) ? @secret.call(@session) : @secret
126:     OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new(@digest), key, data)
127:   end
&lt;/pre&gt;

	&lt;p&gt;Ok, so this meant all I had to was urldecode the cookie, base64 decode the cookie and hash the data so that I could compare the integrity hash passed through the cookie so I knew that I could trust the content. Since the cookies contained a hash from with the secret salt from our environment.rb, I had to make this manually make the &lt;span class="caps"&gt;PHP&lt;/span&gt; side aware of this. How you go about doing this is up to you, for this example let&amp;#8217;s assume I just copied the secret salt from our Rails environment and stuck it in a constant called &lt;span class="caps"&gt;SECRET&lt;/span&gt;_SALT. This was all pretty trivial from the php side of things:&lt;/p&gt;


&lt;pre&gt;
function parse_data_from_cookie( $cookie_name ) {
    $decoded_cookie = urldecode( $_COOKIE[ $cookie_name ] );

    // the cookie is passed through as data--digest, so split these out into their on variables
    list( $encoded_payload, $supplied_digest ) = explode( "--", $decoded_cookie );

    // construct a sha1 integrity hash with the data passed in the cookie and our secret salt
    $generated_digest = hash_hmac( 'sha1', $encoded_payload, SECRET_SALT );

    // can we trust that the data in this cookie came from our rails app and not from some malicious user?
    if ( $supplied_digest == $generated_digest ) {
        $data = base64_decode( $encoded_payload );
        return $data;
    // guess not
    } else {
        return false;
    }
}
&lt;/pre&gt;

	&lt;p&gt;This was working just as you would expect, however there was one caveat that you may have already anticipated. The data passed through in the cookie was actually marshaled Ruby. Because I really only cared about the user_id and none of the other cruft, the simpliest work around was to construct a custom cookie that only contained the user&amp;#8217;s id and that was not marshaled. I did this by making a simple method that would allow me to set all of the custom cookies I want, using the same digest generation and encryption process as the CookieStore was doing. I ended up with something a lot like this:&lt;/p&gt;


&lt;pre&gt;
def set_custom_cookie( key, value )
  data = ActiveSupport::Base64.encode64( value.to_s )
  digest = session.dbman.generate_digest( data )
  cookies[ key ] = CGI.escape( "#{ data }--#{ digest }" )
end
&lt;/pre&gt;

	&lt;p&gt;Note that I&amp;#8217;m using session.dbman to grab the CookieStore instance so that I can reuse the generate_digest method that handles all of the lightwork for me.&lt;/p&gt;


	&lt;p&gt;Now when a user logs in, I just set an additional cookie with that user&amp;#8217;s id in a custom cookie for the &lt;span class="caps"&gt;PHP&lt;/span&gt; side of things. When the user logs out I just delete this cookie. I actually manage the life of this cookie in a slightly different way, but that process is left as an for the reader. On the &lt;span class="caps"&gt;PHP&lt;/span&gt; side of things, if my cookie contains no data, if the digests don&amp;#8217;t match, or if I can&amp;#8217;t find the user in the database matching the passed user_id then I simply redirect them to our login page on the main app.&lt;/p&gt;


	&lt;p&gt;Enjoy.&lt;/p&gt;</description>
      <pubDate>Thu, 10 Apr 2008 13:28:00 CDT</pubDate>
      <guid>http://nicholaswright.org/blog/articles/2008/04/10/persisting-a-logged-from-ror-php</guid>
      <link>http://nicholaswright.org/blog/articles/2008/04/10/persisting-a-logged-from-ror-php</link>
      <category>php</category>
      <category>tips</category>
      <category>rails</category>
      <category>ruby</category>
      <category>code</category>
      <trackback:ping>http://nicholaswright.org/blog/articles/trackback/40</trackback:ping>
    </item>
    <item>
      <title>Injured by Integer</title>
      <description>&lt;p&gt;It&amp;#8217;s been a very long time since I&amp;#8217;ve used &lt;a href="http://www.ruby-doc.org/core/classes/Kernel.html#M005986"&gt;Kernel#Integer&lt;/a&gt;, but to my recollection it was simply coercion that raised an error if necessary, as an alternative to things like &lt;a href="http://www.ruby-doc.org/core/classes/String.html#M000802"&gt;String#to_i&lt;/a&gt; which would simply return the first digits in a string, or 0 if the string did not contain a valid integer.&lt;/p&gt;


	&lt;p&gt;Since the program I was writing was receiving amounts in the form of strings representing cents, I figured it would be a natural fit. Leading zeros would be stripped off of anything under a buck, and I could simply rescue any ArgumentError and handle them appropriately.&lt;/p&gt;


	&lt;p&gt;A short while in production and I&amp;#8217;m starting to get some bug reports that are pretty tricky to replicate.&lt;/p&gt;


	&lt;p&gt;Turns out, my memory has failed me yet again! Integer does not, in fact, do anything close to what I thought it did.&lt;/p&gt;


	&lt;p&gt;Let&amp;#8217;s take a peek inside irb so we can take a harder look at what was causing all of my problems.&lt;/p&gt;


&lt;pre&gt;
&amp;gt;&amp;gt; Integer( "085" )
ArgumentError: invalid value for Integer: "085" 
    from (irb):3:in `Integer'
    from (irb):3
&amp;gt;&amp;gt; Integer( "022" )
=&amp;gt; 18
&lt;/pre&gt;

	&lt;p&gt;Now at a glance you can probably already deduce that I was expecting to get 85 and 22 as the respective results, not an ArgumentError and 18! Keep in mind that I also had a bit of special sauce to handle ArgumentErrors, I just hadn&amp;#8217;t planned on arriving at them through the avenue shown above.&lt;/p&gt;


	&lt;p&gt;A quick peek at the &lt;a href="http://www.ruby-doc.org/core/classes/Kernel.html#M005986"&gt;&lt;span class="caps"&gt;API&lt;/span&gt;&lt;/a&gt; tells me exactly why such behavior was occurring:&lt;/p&gt;


	&lt;p&gt;&amp;#8220;If &lt;em&gt;arg&lt;/em&gt; is a String, leading radix indicators (0, 0b, and 0x) are honored. Others are converted using to_int and to_i.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;Wow. Ok. More than a little unexpected. After having discovered the problem, the bug it caused was easily squashed. Lesson learned, programming from memory is not always a great idea. Even when the tests pass!&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;&lt;span class="caps"&gt;NOTE TO SELF&lt;/span&gt;:&lt;/strong&gt; Kernel#Integer is &lt;em&gt;not&lt;/em&gt; simply an alternative to String#to_i that raises an error.&lt;/p&gt;


	&lt;p&gt;You live, you learn. And then you get luvz.&lt;/p&gt;</description>
      <pubDate>Fri,  4 Apr 2008 21:35:00 CDT</pubDate>
      <guid>http://nicholaswright.org/blog/articles/2008/04/04/injured-by-integer</guid>
      <link>http://nicholaswright.org/blog/articles/2008/04/04/injured-by-integer</link>
      <category>tips</category>
      <category>ruby</category>
      <trackback:ping>http://nicholaswright.org/blog/articles/trackback/39</trackback:ping>
    </item>
    <item>
      <title>Little man finally rocketed</title>
      <description>&lt;p&gt;I&amp;#8217;ve finally gotten around to playing and beating Half-life 2 episode 2.&lt;/p&gt;


	&lt;p&gt;I knew before I even began playing the game that I absolutely had to &lt;a href="http://www.pentadact.com/index.php/2007-10-15-gnome-quest"&gt;snag that Gnome achievement&lt;/a&gt; during my first play through.&lt;/p&gt;


	&lt;p&gt;All I knew going in was that the Gnome was somewhere near the beginning, and that I had to launch him into space somewhere near the end. I was right, he was indeed near the beginning, and I did infact have to launch him into space.&lt;/p&gt;


	&lt;p&gt;What I was tragically unaware of, however, was that the section where you put your little buddy (which I&amp;#8217;ve affectionately named &amp;#8216;Greggory&amp;#8217;) into the rocket was not at the end of the game. Sure it was near the end, but it wasn&amp;#8217;t &lt;em&gt;at&lt;/em&gt; the end.&lt;/p&gt;


	&lt;p&gt;As this was my first play through, I was also really worried about losing him before hitting some checkpoint that I wasn&amp;#8217;t expecting, so I kept him close by me through the entire game.&lt;/p&gt;


	&lt;p&gt;When I walked into the control room at the end, I was a bit puzzled when I was told to press the button to launch the rocket. Seconds before, Dr. Kliener even made some comment about how the rocket was approximately 8 and a half pounds under weight! I figured something would go wrong during the launch and I would be asked to go down to the rocket and deposit something in there of weight (at this point I was starting to get a bit annoyed and was really grasping for straws.)&lt;/p&gt;


	&lt;p&gt;Of course, this never happened, and the rocket happily launched straight into the air. It was while everyone was celebrating the successful launch that I went through my old saves and managed to find one directly before the race to White Forest with Dog that I had made so I could beat him, get the achievement, and go back to grab Greggory and continue on my way.&lt;/p&gt;


	&lt;p&gt;I loaded the save file and made my way back up to White Forest, by this point reserved to the fact that I&amp;#8217;d have to do the Silo 2 clearance and 12 Strider battle yet again.&lt;/p&gt;


	&lt;p&gt;I figured the best I could hope for was that I could stick Greggory into the rocket, create another save file, then go back to the beginning of T-minus One and relaunch the rocket, just in case there would be some sweet glitch in my favor that would pick up that he was stuck in the rocket at one point and then I&amp;#8217;d get my achievement after the credits rolled (one thing I had known was that you don&amp;#8217;t see the achievement pop up, but it does actually appear unlocked after you finish the game and sit through the credits.)&lt;/p&gt;


	&lt;p&gt;Thankfully, after throwing him at lamar and slamming the door shut, I was rewarded with my very own Little Rocket Man achievement! I was sooooo happy that I didn&amp;#8217;t have to finish the rest of the game yet again.&lt;/p&gt;


	&lt;p&gt;Still, I can&amp;#8217;t help but wonder how many people actually made much more work for themselves by carrying the little guy for another hour and some change? I&amp;#8217;d feel way better if the answer to that question was &amp;#8220;A very large number&amp;#8221;.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m now taking it upon myself to trick people into getting caught in the same trap as myself (Jon, Alex, I pray that you guys don&amp;#8217;t subscribe to my feed&amp;#8230; &lt;span class="caps"&gt;MUWAHAHAHA&lt;/span&gt;.)&lt;/p&gt;


	&lt;p&gt;At any rate, once I had achievement in hand I fast forwarded back to the launch and finished watching the game. Such an unexpected ending!&lt;/p&gt;


	&lt;p&gt;Roll on &lt;span class="caps"&gt;EP3&lt;/span&gt;.&lt;/p&gt;</description>
      <pubDate>Thu,  3 Apr 2008 23:15:00 CDT</pubDate>
      <guid>http://nicholaswright.org/blog/articles/2008/04/03/little-man-finally-rocketed</guid>
      <link>http://nicholaswright.org/blog/articles/2008/04/03/little-man-finally-rocketed</link>
      <category>ridiculous</category>
      <category>gaming</category>
      <trackback:ping>http://nicholaswright.org/blog/articles/trackback/38</trackback:ping>
    </item>
    <item>
      <title>Hot Potatowned</title>
      <description>&lt;p&gt;&lt;img src="http://www.a3share.com/members/108637/1199326423753.jpg" /&gt;&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s really all I have to say about that.&lt;/p&gt;</description>
      <pubDate>Thu,  3 Jan 2008 20:00:30 CST</pubDate>
      <guid>http://nicholaswright.org/blog/articles/2008/01/03/hot-potatowned</guid>
      <link>http://nicholaswright.org/blog/articles/2008/01/03/hot-potatowned</link>
      <category>gaming</category>
      <trackback:ping>http://nicholaswright.org/blog/articles/trackback/37</trackback:ping>
    </item>
    <item>
      <title>Nothing or not</title>
      <description>&lt;p&gt;Everyone loves writing web apps. They&amp;#8217;re just amazing at doing everything. Ever.&lt;/p&gt;


	&lt;p&gt;One of the more interesting aspects of writing web applications is how often you see yourself doing the same thing over and over again.&lt;/p&gt;


	&lt;p&gt;It&amp;#8217;s a very common task, for instance, to grab some list of records and loop through and display them on a page. But what happens when no records are found?&lt;/p&gt;


	&lt;p&gt;There are oft used methods for doing this.&lt;/p&gt;


	&lt;p&gt;The first of these is to simply hide the entire block of code from displaying. Such as follows:&lt;/p&gt;


&lt;pre&gt;
&amp;lt;% unless @results.blank? %&amp;gt;
  &amp;lt;% @results.each do | result | %&amp;gt;
    ...
  &amp;lt;% end %&amp;gt;
&amp;lt;% end %&amp;gt;
&lt;/pre&gt;

	&lt;p&gt;The second method takes slightly more work, and lends itself to much more duplication across your app. This approach is to actually display a message stating that nothing has been found, such as thus:&lt;/p&gt;


&lt;pre&gt;
&amp;lt;% unless @results.blank? %&amp;gt;
  &amp;lt;% @results.each do | result | %&amp;gt;
    ...
  &amp;lt;% end %&amp;gt;
&amp;lt;% else %&amp;gt;
  &amp;lt;p class="empty"&amp;gt;
    Nothing to display!
  &amp;lt;p&amp;gt;
&amp;lt;% end %&amp;gt;
&lt;/pre&gt;

	&lt;p&gt;It would be great if you could do the second version just as simply as you would the first. The obvious answer would be to use a helper. But how? How would you create something to do this?&lt;/p&gt;


	&lt;p&gt;The answer comes from two wonderfully useful helper methods made available to you by Rails. These, of course, are &lt;a href="http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M001035"&gt;concat&lt;/a&gt; and &lt;a href="http://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#M001055"&gt;capture&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;So now that we have the building blocks, how would we put them together to create a useful new construct that can be used as in an almost identical way to the first solution above? Maybe we want something that would look like this:&lt;/p&gt;


&lt;pre&gt;
&amp;lt;% unless_blank( @results ) do %&amp;gt;
  &amp;lt;% @results.each do | result | %&amp;gt;
    ...
  &amp;lt;% end %&amp;gt;
&amp;lt;% end %&amp;gt;
&lt;/pre&gt;

	&lt;p&gt;Well that&amp;#8217;s simple enough. We get the above functionality by sticking the following code into our application helper.&lt;/p&gt;


&lt;pre&gt;
  def unless_blank( obj, &amp;#38;block )
    content = unless obj.blank?
      capture( &amp;#38;block )
    else
      %{ &amp;lt;p class="empty"&amp;gt;Nothing found.&amp;lt;/p&amp;gt; }
    end
    concat( content, block.binding )
  end
&lt;/pre&gt;

	&lt;p&gt;Hmm. That&amp;#8217;s actually kind of neat, but what is really going on here?&lt;/p&gt;


	&lt;p&gt;This isn&amp;#8217;t mysterious at all. At a glance you will note that we&amp;#8217;re just assigning the captured block to the content variable if our object is not blank, and if it is then we&amp;#8217;re just using some html with a little message to state so. Right now some curious readers may question, then, why we actually need to capture our block at all? Why can&amp;#8217;t we just call the block if our object is not blank, setting content to the results directly.&lt;/p&gt;


	&lt;p&gt;The nutshell answer to this question is that without using &amp;#8216;capture&amp;#8217; we&amp;#8217;re going to be displaying 2 copies of the results of block later on when we concatenate the results to our binding. I invite you to try different variations of this code, with and without the capture segment, to see the difference between the two at a glance.&lt;/p&gt;


But what about concat? Well, you may have also noticed in the above example that we weren&amp;#8217;t doing erb output anywhere. That&amp;#8217;s where concat comes into play. The content variable is taken and appended onto the end of our current erb string. The result of this is that whenever we use concat to add content to the end of our binding, we&amp;#8217;re effectively (for all intents and purposes) doing:
&lt;pre&gt;&amp;lt;%= content %&amp;gt;&lt;/pre&gt;

	&lt;p&gt;These give us a powerful way to create helpers that can handle some of our more common view patterns with little trouble. So grab a towel and dry up those sopping wet views!&lt;/p&gt;</description>
      <pubDate>Wed, 12 Dec 2007 13:22:00 CST</pubDate>
      <guid>http://nicholaswright.org/blog/articles/2007/12/12/nothing-or-not</guid>
      <link>http://nicholaswright.org/blog/articles/2007/12/12/nothing-or-not</link>
      <category>rails</category>
      <category>tips</category>
      <category>code</category>
      <category>ruby</category>
      <trackback:ping>http://nicholaswright.org/blog/articles/trackback/36</trackback:ping>
    </item>
    <item>
      <title>You suuure did</title>
      <description>&lt;p&gt;&lt;a href="http://www.metacafe.com/watch/928700/the_master_of_balls/"&gt;People never cease to amaze me&lt;/a&gt;. It just blows me away that anybody can find enough time in their lives to learn such weird stuff. I suppose it&amp;#8217;s just like any other hobby though, right? I wonder if he gets paid for those skills..&lt;/p&gt;</description>
      <pubDate>Tue, 20 Nov 2007 14:16:01 CST</pubDate>
      <guid>http://nicholaswright.org/blog/articles/2007/11/20/you-suuure-did</guid>
      <link>http://nicholaswright.org/blog/articles/2007/11/20/you-suuure-did</link>
      <category>ridiculous</category>
      <trackback:ping>http://nicholaswright.org/blog/articles/trackback/35</trackback:ping>
    </item>
    <item>
      <title>POP This!</title>
      <description>&lt;p&gt;Like every other go-go 80s dollar jockey, one of my first actions on my iPhone was to setup my email accounts.&lt;/p&gt;


	&lt;p&gt;This is where I ran into a problem. I&amp;#8217;d select GMail from the list, but for some reason &lt;span class="caps"&gt;POP&lt;/span&gt; was required, and no matter what I tried I couldn&amp;#8217;t use &lt;span class="caps"&gt;IMAP&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;I dealt with &lt;span class="caps"&gt;POP&lt;/span&gt; for few days, but it&amp;#8217;s excruciating considering the glaring lack of &amp;#8216;Mark all as Read&amp;#8217; options on the iPhone&amp;#8217;s Mail app.&lt;/p&gt;


	&lt;p&gt;Fast forward to 2 hours ago and I was yet again setting up another email account on my iPhone, this time it was for work, but once again it was a precious GMail account.&lt;/p&gt;


	&lt;p&gt;I did a bit of googling to grab the outgoing and incoming mail servers and stumbled across &lt;a href="https://mail.google.com/support/bin/answer.py?answer=77702"&gt;this beautiful document&lt;/a&gt; that states there is a bug in the GMail setup on the iPhone that limits you to using &lt;span class="caps"&gt;POP&lt;/span&gt;. The short answer was to select the &amp;#8216;Other&amp;#8217; option, which I&amp;#8217;d somehow completely scanned over.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m now sitting pretty with my GMail accounts happily &lt;span class="caps"&gt;IMA&lt;/span&gt;Ping away. No more duplication! Happy iPhoning.&lt;/p&gt;</description>
      <pubDate>Sun, 18 Nov 2007 16:32:00 CST</pubDate>
      <guid>http://nicholaswright.org/blog/articles/2007/11/18/pop-this</guid>
      <link>http://nicholaswright.org/blog/articles/2007/11/18/pop-this</link>
      <category>iphone</category>
      <category>gadgets</category>
      <trackback:ping>http://nicholaswright.org/blog/articles/trackback/34</trackback:ping>
    </item>
    <item>
      <title>Where's the cake?</title>
      <description>&lt;p&gt;I can&amp;#8217;t help but feel that value of &lt;a href="http://en.wikipedia.org/wiki/The_Orange_Box"&gt;The Orange Box&lt;/a&gt; is far understated. I know everyone is hyped on it and each game has gotten a really high score, but it&amp;#8217;s worth reiterating just how awesome the content in The Orange Box is.&lt;/p&gt;


	&lt;p&gt;Take &lt;a href="http://en.wikipedia.org/wiki/Portal_%28video_game%29"&gt;Portal&lt;/a&gt;, for example. I found the game to be really hilarious and thought provoking. Sure it&amp;#8217;s not the hardest game in the world, or even the longest, but compared to the quality of most current gen titles it&amp;#8217;s well worth the full 50 bucks other games receive. There&amp;#8217;s also apparently going to be downloadable content that lets you play on harder difficulties? This game rocks! I can&amp;#8217;t wait for another outing.&lt;/p&gt;


	&lt;p&gt;There&amp;#8217;s just something special about a &lt;a href="http://en.wikipedia.org/wiki/Valve_Corporation"&gt;Valve&lt;/a&gt; title. From the humor to the almost branded style it&amp;#8217;s just magic.&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s why, after having beat Portal, I was very pleased (but not surprised) to be treated to what&amp;#8217;s got to be the most entertaining credits roll I&amp;#8217;ve ever seen. The song is going straight on my playlist.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ve found a &lt;a href="http://youtube.com/watch?v=KjGfgV7rJHI"&gt;youtube video&lt;/a&gt; of the song, without the credits or anything else so it doesn&amp;#8217;t really ruin it for you.&lt;/p&gt;


	&lt;p&gt;I say kudos to Valve for releasing such a fabulous package for such a reasonable price. I look forward to Portal 2!&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; The Aperture Science Weighted Companion Cube &lt;a href="http://www.myspace.com/thereisnocake"&gt;has it&amp;#8217;s own myspace profile&lt;/a&gt;! Hahaha. Golden.&lt;/p&gt;</description>
      <pubDate>Wed, 14 Nov 2007 17:15:00 CST</pubDate>
      <guid>http://nicholaswright.org/blog/articles/2007/11/14/wheres-the-cake</guid>
      <link>http://nicholaswright.org/blog/articles/2007/11/14/wheres-the-cake</link>
      <category>gaming</category>
      <trackback:ping>http://nicholaswright.org/blog/articles/trackback/33</trackback:ping>
    </item>
  </channel>
</rss>
