<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>sneaq.</title>
    <description>Stomping on a human face for 30 seconds at a time</description>
    <link>http://sneaq.net/</link>
    <item>
      <title>TextMate ... WTF?</title>
      <description>&lt;p&gt;Like any good Ruby developer working on a fresh bit of code, you eagerly start setting up to run your first test and get hit with this in TextMate:&lt;/p&gt;

&lt;div class="CodeRay"&gt;
  &lt;div class="code"&gt;&lt;pre&gt;
  `blank_slate_method_added': stack level too deep (SystemStackError)
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Ouch.  Screeching halt.  The root cause for this comes from a conflict between TextMate's version of &lt;a href="http://onestepback.org/index.cgi/Tech/Ruby/BuilderObjects.rdoc"&gt;Builder&lt;/a&gt; and the system-installed version.  There are a couple solutions floating out there - either &lt;a href="http://robsanheim.com/2007/12/07/fixing-textmate-test-issues-blank_slate_method_added-stack-level-too-deep-systemstackerror/"&gt;remove the TextMate-bundled version&lt;/a&gt; entirely or drop this in your test file:&lt;/p&gt;

&lt;div class="CodeRay"&gt;
  &lt;div class="code"&gt;&lt;pre&gt;
  &lt;span style="color:#d70; font-weight:bold"&gt;$:&lt;/span&gt;.reject! { |e| e.include? &lt;span style="background-color:#fff0f0"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style="color:#D20"&gt;TextMate&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt; }
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;I prefer this method as it doesn't have any noticeable side effects anywhere I've used it.  This appears to be the &lt;a href="http://ticket.macromates.com/show?ticket_id=F4DA8B03"&gt;official solution&lt;/a&gt; to date.&lt;/p&gt;</description>
      <pubDate>Sat, 22 Nov 2008 03:09:14 +0000</pubDate>
      <link>http://sneaq.net/textmate-wtf</link>
      <guid>http://sneaq.net/textmate-wtf</guid>
    </item>
    <item>
      <title>Rails Rumble '08: Redux</title>
      <description>&lt;p&gt;It's been a few weeks since &lt;a href="http://robares.com"&gt;Rob&lt;/a&gt;, &lt;a href="http://simpltry.com"&gt;Nic&lt;/a&gt;, &lt;a href="http://blog.thedougaveryexperience.com/"&gt;Doug&lt;/a&gt;, and I competed in this year's &lt;a href="http://railsrumble.com"&gt;RailsRumble&lt;/a&gt; - after the dust settled from the 48-hour competition we had created an app (&lt;a href="http://qflip.net"&gt;Qflip&lt;/a&gt;) that went on to take 2nd place.  From what I can remember, it was both fun and stressful - check out the &lt;a href="http://www.flickr.com/photos/viget/sets/72157608526245671/"&gt;Flickr photos&lt;/a&gt; for proof.&lt;/p&gt;

&lt;p&gt;Doug shared his take from the event on the &lt;a href="http://www.viget.com/inspire/under-pressure-lessons-learned/"&gt;Viget Inspire&lt;/a&gt; blog and described a technique that I think shows a lot of promise for design and development teams working together:&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;Do you know what all the pages do? How they're structured, and what they
    communicate? Great, now build them. Using just markup and some gray
    backgrounds, you can make a working version of your site in no time flat.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I documented my experience over at &lt;a href="http://www.viget.com/extend/fast-cheap-and-good-my-rails-rumble-experience/"&gt;Extend&lt;/a&gt; and reinforced the importance of "shipping":&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;...Our codes were far from perfect, but we realized that the real value was in
    getting a product out there that could be used in the way it was intended by a
    real audience. As a result we now have real feedback and focused ideas on how
    to make the application even better.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Since the event, we've increasingly seen continued usage and coverage of the application:&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;QFlip - Get strangers to influence your Netflix queue. Sounds scary, but you
    might end up with some interesting picks! Developed by the wonderfully named
    "Scatapult" team.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&amp;mdash; &lt;a href="http://www.railsinside.com/news/144-railsrumble-2008-winners-announced.html"&gt;Rails Inside&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;Qflip is an interesting service that uses Netflix&#8217;s open API to help
    subscribers make movie choices.  What I like about this service:&lt;/p&gt;
    
    &lt;ul&gt;
    &lt;li&gt;It&#8217;s quick and easy&lt;/li&gt;
    &lt;li&gt;It provides value to my Netflix membership&lt;/li&gt;
    &lt;li&gt;It&#8217;s fun in that it has an element of surprise and randomness&lt;/li&gt;
    &lt;li&gt;It&#8217;s based on people, not algorithms&lt;/li&gt;
    &lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;&amp;mdash; &lt;a href="http://tomwillerer.com/post/56036832/qflip-is-an-interesting-service-that-uses"&gt;Tom Willerer&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;If you are a Netflix user with friends' of the same movie-renting persuasion,
    and you have an evil sense of humor, this is your app.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&amp;mdash; &lt;a href="http://www.networkworld.com/slideshows/2008/111108-amazing-ruby.html"&gt;NetworkWorld&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;QFlip is a Netflix hack that enables other people to mess with your queue. I'm
    not brave enough to try it, but if you do let us know what you think in the
    comments.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&amp;mdash; &lt;a href="http://www.hackingnetflix.com/2008/11/qflip-netflix-w.html"&gt;Hacking Netflix.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We plan to continue working on the app and reacting to feedback that we get from our users.  As part of that work, we will be extracting the Netflix-specific functionality into a &lt;a href="http://github.com/rares/netflix"&gt;publicly-available Gem&lt;/a&gt;.  Stay tuned.&lt;/p&gt;</description>
      <pubDate>Wed, 19 Nov 2008 05:21:06 +0000</pubDate>
      <link>http://sneaq.net/rails-rumble-08-redux</link>
      <guid>http://sneaq.net/rails-rumble-08-redux</guid>
    </item>
    <item>
      <title>Gems. Simple.</title>
      <description>&lt;p&gt;I've written a few Ruby Gems in my time, it's true.  In my experience it's always been a bit of a painful process - I could never come to grips with all the dependencies that &lt;a href="http://seattlerb.rubyforge.org/hoe/"&gt;hoe&lt;/a&gt; introduced and I always ended up reconfiguring things after running &lt;a href="http://newgem.rubyforge.org"&gt;&lt;code&gt;newgem --simple&lt;/code&gt;&lt;/a&gt;. So... I decided to write my own little gem that generates, well, gems.&lt;/p&gt;

&lt;h2&gt;Getting It&lt;/h2&gt;

&lt;p&gt;This should be all you need:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo gem install reagent-simple-gem --source http://gems.github.com
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If that doesn't work, take a look at the &lt;a href="http://github.com/reagent/simple-gem/tree/master/README.markdown"&gt;README out on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Using It&lt;/h2&gt;

&lt;p&gt;Ready? Go.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ simple-gem my-gem
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now you have a &lt;a href="http://www.dialbforblog.com/archives/133/crimson_ghost1.jpg"&gt;skeleton&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;my-gem/
|-- README.markdown
|-- Rakefile
|-- lib
|   |-- my_gem
|   |   `-- version.rb
|   `-- my_gem.rb
`-- test
    `-- my_gem_test.rb
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Write your codes, test them, and release:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ cd my-gem
$ rake github
$ git add &amp;amp;&amp;amp; git commit -m "Perfection."
$ git push origin master
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;There's more to it, but that's the basic idea.  &lt;a href="http://github.com/reagent/simple-gem/tree/master/README.markdown"&gt;Check out the docs&lt;/a&gt; for more information and &lt;a href="mailto:reaganpr@gmail.com"&gt;send me your feedback&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 02 Nov 2008 20:24:56 +0000</pubDate>
      <link>http://sneaq.net/gems-simple</link>
      <guid>http://sneaq.net/gems-simple</guid>
    </item>
    <item>
      <title>Salt on a Slug</title>
      <description>&lt;p&gt;Here's a quick way to generate slugs to use as part of a URL for things like posts, categories, etc...&lt;/p&gt;

&lt;div class="CodeRay"&gt;
  &lt;div class="code"&gt;&lt;pre&gt;
&lt;span style="color:#080; font-weight:bold"&gt;class&lt;/span&gt; &lt;span style="color:#B06; font-weight:bold"&gt;String&lt;/span&gt;
  &lt;span style="color:#080; font-weight:bold"&gt;def&lt;/span&gt; &lt;span style="color:#06B; font-weight:bold"&gt;sluggify&lt;/span&gt;
    slug = &lt;span style="color:#038; font-weight:bold"&gt;self&lt;/span&gt;.downcase.gsub(&lt;span style="background-color:#fff0ff"&gt;&lt;span style="color:#404"&gt;/&lt;/span&gt;&lt;span style="color:#808"&gt;[^0-9a-z_ -]&lt;/span&gt;&lt;span style="color:#404"&gt;/&lt;/span&gt;&lt;span style="color:#C2C"&gt;i&lt;/span&gt;&lt;/span&gt;, &lt;span style="background-color:#fff0f0"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;)
    slug = slug.gsub(&lt;span style="background-color:#fff0ff"&gt;&lt;span style="color:#404"&gt;/&lt;/span&gt;&lt;span style="color:#04D"&gt;\s&lt;/span&gt;&lt;span style="color:#808"&gt;+&lt;/span&gt;&lt;span style="color:#404"&gt;/&lt;/span&gt;&lt;/span&gt;, &lt;span style="background-color:#fff0f0"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style="color:#D20"&gt;-&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;)
    slug
  &lt;span style="color:#080; font-weight:bold"&gt;end&lt;/span&gt;
&lt;span style="color:#080; font-weight:bold"&gt;end&lt;/span&gt;

&lt;span style="color:#080; font-weight:bold"&gt;class&lt;/span&gt; &lt;span style="color:#B06; font-weight:bold"&gt;NilClass&lt;/span&gt;
  &lt;span style="color:#080; font-weight:bold"&gt;def&lt;/span&gt; &lt;span style="color:#06B; font-weight:bold"&gt;sluggify&lt;/span&gt;
    &lt;span style="background-color:#fff0f0"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;
  &lt;span style="color:#080; font-weight:bold"&gt;end&lt;/span&gt;
&lt;span style="color:#080; font-weight:bold"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Here's what it looks like in action:&lt;/p&gt;

&lt;div class="CodeRay"&gt;
  &lt;div class="code"&gt;&lt;pre&gt;
$ irb
&amp;gt;&amp;gt; 'This is a post'.sluggify
=&amp;gt; &amp;quot;this-is-a-post&amp;quot;
&amp;gt;&amp;gt; nil.sluggify
=&amp;gt; &amp;quot;&amp;quot;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;</description>
      <pubDate>Sun, 26 Oct 2008 11:31:23 +0000</pubDate>
      <link>http://sneaq.net/salt-on-a-slug</link>
      <guid>http://sneaq.net/salt-on-a-slug</guid>
    </item>
    <item>
      <title>Developing a Product Sometimes Means Removing Features</title>
      <description>&lt;p&gt;As part of my &lt;a href="http://www.viget.com"&gt;daily job&lt;/a&gt;, we're constantly balancing business value with level of effort when planning which features to include in an upcoming iteration.  After reviewing an iteration's work with a client, follow-on conversations usually revolve around adding new features to the product. I was glad to see that &lt;a href="http://digg.com"&gt;Digg&lt;/a&gt; sometimes has a &lt;a href="http://blog.digg.com/?p=289"&gt;different approach&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;In the next week or so, we&#8217;ll be closing down the podcasts section and folding
    it into the video section of Digg. We&#8217;ll also be retiring the old Digg Spy. Both
    of these features have become outmoded as Digg has grown and as a result they
    have a very small number of users (under 1,000) each.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I think that the key to this sort of activity is having a clear reason to remove a feature.  In Digg's case, they were keeping an eye on their metrics and were able to justify the removal of both features based on quantifiable evidence.&lt;/p&gt;

&lt;p&gt;In the early stages of development, it's not always an option to remove a feature.  The best way to make this happen is to launch early and often and let your users decide which features are valuable and which ones aren't.&lt;/p&gt;</description>
      <pubDate>Sat, 11 Oct 2008 11:39:47 +0000</pubDate>
      <link>http://sneaq.net/developing-a-product-sometimes-means-removing-features</link>
      <guid>http://sneaq.net/developing-a-product-sometimes-means-removing-features</guid>
    </item>
    <item>
      <title>Simple</title>
      <description>&lt;p&gt;2 ways:&lt;/p&gt;

&lt;div class="CodeRay"&gt;
  &lt;div class="code"&gt;&lt;pre&gt;
$ alias irb='irb --prompt simple'
$ echo &amp;quot;IRB.conf[:PROMPT_MODE] = :SIMPLE&amp;quot; &amp;gt;&amp;gt; ~/.irbrc
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;</description>
      <pubDate>Mon, 06 Oct 2008 18:31:51 +0000</pubDate>
      <link>http://sneaq.net/simple</link>
      <guid>http://sneaq.net/simple</guid>
    </item>
    <item>
      <title>Tracking Changes in Git</title>
      <description>&lt;p&gt;I've always heard people refer to creating 'tracking branches' but never really knew how to set one up.  I think I've figured it out - here's my current workflow:&lt;/p&gt;

&lt;div class="CodeRay"&gt;
  &lt;div class="code"&gt;&lt;pre&gt;
  $ git clone my_git_repo
  $ git remote add other_source other_git_repo
  $ git fetch other_source
  $ git branch --track other_source_master other_source/master
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Once I have that set up, I can integrate others' changes:&lt;/p&gt;

&lt;div class="CodeRay"&gt;
  &lt;div class="code"&gt;&lt;pre&gt;
  $ git checkout master
  $ git checkout -b merge_area
  $ git merge other_source_master
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Any time I want to pull upstream changes from the other remote source:&lt;/p&gt;

&lt;div class="CodeRay"&gt;
  &lt;div class="code"&gt;&lt;pre&gt;
  $ git checkout other_source_master
  $ git pull
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;</description>
      <pubDate>Sun, 05 Oct 2008 11:13:04 +0000</pubDate>
      <link>http://sneaq.net/tracking-changes-in-git</link>
      <guid>http://sneaq.net/tracking-changes-in-git</guid>
    </item>
    <item>
      <title>Unit Testing Your ApplicationController</title>
      <description>&lt;p&gt;Do it!&lt;/p&gt;

&lt;div class="CodeRay"&gt;
  &lt;div class="code"&gt;&lt;pre&gt;
&lt;span style="color:#080; font-weight:bold"&gt;class&lt;/span&gt; &lt;span style="color:#B06; font-weight:bold"&gt;ApplicationControllerTest&lt;/span&gt; &amp;lt; &lt;span style="color:#036; font-weight:bold"&gt;ActiveSupport&lt;/span&gt;::&lt;span style="color:#036; font-weight:bold"&gt;TestCase&lt;/span&gt;
  context &lt;span style="background-color:#fff0f0"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#D20"&gt;An instance of ApplicationController&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#080; font-weight:bold"&gt;do&lt;/span&gt;

    setup { &lt;span style="color:#33B"&gt;@controller&lt;/span&gt; = &lt;span style="color:#036; font-weight:bold"&gt;ApplicationController&lt;/span&gt;.new }

    should &lt;span style="background-color:#fff0f0"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#D20"&gt;return nil when there is no :user_id in session&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#080; font-weight:bold"&gt;do&lt;/span&gt;
      &lt;span style="color:#33B"&gt;@controller&lt;/span&gt;.stubs(&lt;span style="color:#A60"&gt;:session&lt;/span&gt;).returns({})
      assert_nil &lt;span style="color:#33B"&gt;@controller&lt;/span&gt;.current_user
    &lt;span style="color:#080; font-weight:bold"&gt;end&lt;/span&gt;

    should &lt;span style="background-color:#fff0f0"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#D20"&gt;retrieve the current user when there is a :user_id in session&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#080; font-weight:bold"&gt;do&lt;/span&gt;
      user = Factory(&lt;span style="color:#A60"&gt;:user&lt;/span&gt;)
      &lt;span style="color:#33B"&gt;@controller&lt;/span&gt;.stubs(&lt;span style="color:#A60"&gt;:session&lt;/span&gt;).returns({&lt;span style="color:#A60"&gt;:user_id&lt;/span&gt; =&amp;gt; user.id})

      assert_equal user, &lt;span style="color:#33B"&gt;@controller&lt;/span&gt;.current_user
    &lt;span style="color:#080; font-weight:bold"&gt;end&lt;/span&gt;

    should &lt;span style="background-color:#fff0f0"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#D20"&gt;return nil when the :user_id in session can't be found in the database&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#080; font-weight:bold"&gt;do&lt;/span&gt;
      &lt;span style="color:#33B"&gt;@controller&lt;/span&gt;.stubs(&lt;span style="color:#A60"&gt;:session&lt;/span&gt;).returns(&lt;span style="color:#A60"&gt;:user_id&lt;/span&gt; =&amp;gt; &lt;span style="color:#00D; font-weight:bold"&gt;1&lt;/span&gt;)

      assert_nil &lt;span style="color:#33B"&gt;@controller&lt;/span&gt;.current_user
    &lt;span style="color:#080; font-weight:bold"&gt;end&lt;/span&gt;

  &lt;span style="color:#080; font-weight:bold"&gt;end&lt;/span&gt;
&lt;span style="color:#080; font-weight:bold"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;</description>
      <pubDate>Tue, 30 Sep 2008 19:28:34 +0000</pubDate>
      <link>http://sneaq.net/unit-testing-your-applicationcontroller</link>
      <guid>http://sneaq.net/unit-testing-your-applicationcontroller</guid>
    </item>
    <item>
      <title>Setting Session Data the Old-School Way</title>
      <description>&lt;p&gt;Rails provides an easy way to send session data in functional tests when accessing an action (the 3rd parameter is session data):&lt;/p&gt;

&lt;div class="CodeRay"&gt;
  &lt;div class="code"&gt;&lt;pre&gt;
  get &lt;span style="color:#A60"&gt;:index&lt;/span&gt;, {}, {&lt;span style="color:#A60"&gt;:user_id&lt;/span&gt; =&amp;gt; &lt;span style="color:#00D; font-weight:bold"&gt;1&lt;/span&gt;}
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;As you add to your functional test suite, this becomes quite tedious and doesn't play well with tools like &lt;a href="http://www.thoughtbot.com/projects/shoulda"&gt;Shoulda&lt;/a&gt;.  Here's where doing it the old-school way helps:&lt;/p&gt;

&lt;div class="CodeRay"&gt;
  &lt;div class="code"&gt;&lt;pre&gt;
context &lt;span style="background-color:#fff0f0"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#D20"&gt;A GET to :index&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#080; font-weight:bold"&gt;do&lt;/span&gt;
  context &lt;span style="background-color:#fff0f0"&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#D20"&gt;as a logged-in user&lt;/span&gt;&lt;span style="color:#710"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span style="color:#080; font-weight:bold"&gt;do&lt;/span&gt;
    setup &lt;span style="color:#080; font-weight:bold"&gt;do&lt;/span&gt;
      &lt;span style="color:#33B"&gt;@request&lt;/span&gt;.session[&lt;span style="color:#A60"&gt;:user_id&lt;/span&gt;] = Factory(&lt;span style="color:#A60"&gt;:user&lt;/span&gt;).id
      get &lt;span style="color:#A60"&gt;:index&lt;/span&gt;
    &lt;span style="color:#080; font-weight:bold"&gt;end&lt;/span&gt;

    should_assign_to &lt;span style="color:#A60"&gt;:messages&lt;/span&gt;      
    should_render_template &lt;span style="background-color:#fff0f0"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style="color:#D20"&gt;index&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;
  &lt;span style="color:#080; font-weight:bold"&gt;end&lt;/span&gt;
&lt;span style="color:#080; font-weight:bold"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Thanks to &lt;a href="http://github.com/mig"&gt;Matt&lt;/a&gt; for giving me a hand with this today.&lt;/p&gt;</description>
      <pubDate>Mon, 29 Sep 2008 17:54:21 +0000</pubDate>
      <link>http://sneaq.net/setting-session-data-the-old-school-way</link>
      <guid>http://sneaq.net/setting-session-data-the-old-school-way</guid>
    </item>
    <item>
      <title>Overwriting "Constants"</title>
      <description>&lt;p&gt;In Ruby, constants aren't the same as in other languages since you can change them at runtime. This code:&lt;/p&gt;

&lt;div class="CodeRay"&gt;
  &lt;div class="code"&gt;&lt;pre&gt;
&lt;span style="color:#036; font-weight:bold"&gt;ENDPOINT_URL&lt;/span&gt; = &lt;span style="background-color:#fff0f0"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style="color:#D20"&gt;http://mysubdomain.unfuddle.com/api/v1/&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;span style="color:#036; font-weight:bold"&gt;ENDPOINT_URL&lt;/span&gt; = &lt;span style="background-color:#fff0f0"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style="color:#D20"&gt;http://othersubdomain.unfuddle.com/api/v1/&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;
puts &lt;span style="color:#036; font-weight:bold"&gt;ENDPOINT_URL&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;produces this output (including the warning):&lt;/p&gt;

&lt;div class="CodeRay"&gt;
  &lt;div class="code"&gt;&lt;pre&gt;
warning: already initialized constant ENDPOINT_URL
http://othersubdomain.unfuddle.com/api/v1/
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;If you need to override a constant and don't want to trigger a warning (in a test environment, for example) you can use the &lt;tt&gt;replace&lt;/tt&gt; method:&lt;/p&gt;

&lt;div class="CodeRay"&gt;
  &lt;div class="code"&gt;&lt;pre&gt;
&lt;span style="color:#036; font-weight:bold"&gt;ENDPOINT_URL&lt;/span&gt; = &lt;span style="background-color:#fff0f0"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style="color:#D20"&gt;http://mysubdomain.unfuddle.com/api/v1/&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;span style="color:#036; font-weight:bold"&gt;ENDPOINT_URL&lt;/span&gt;.replace &lt;span style="background-color:#fff0f0"&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;span style="color:#D20"&gt;http://othersubdomain.unfuddle.com/api/v1/&lt;/span&gt;&lt;span style="color:#710"&gt;'&lt;/span&gt;&lt;/span&gt;
puts &lt;span style="color:#036; font-weight:bold"&gt;ENDPOINT_URL&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This will only work with those objects that have a &lt;tt&gt;replace&lt;/tt&gt; method defined (e.g. Array, Hash, and String) and the new value must have the same datatype.&lt;/p&gt;</description>
      <pubDate>Thu, 25 Sep 2008 16:33:39 +0000</pubDate>
      <link>http://sneaq.net/overwriting-constants</link>
      <guid>http://sneaq.net/overwriting-constants</guid>
    </item>
  </channel>
</rss>
