Author: Matthew

  • Radiant can’t load ActiveSupport caching?

    Are you getting this error message when attempting to deploy your Radiant application?

    no such file to load -- active_support/cache/memory_store
    

    The fix is simple. Assuming you’re using a vendored copy of Radiant or Rails, you probably have an entry for “cache” in your .gitignore file or your svn:ignore property. Remove it, commit the changes, and deploy again. Bingo!

    Don’t ask me how I know this.

  • Autumn beauty at Hanging Rock

    In November, I was blessed with the opportunity to visit Hanging Rock State Park with some friends from church. Though the fall colors were past peak, it was still an enjoyable and invigorating hike. I took this video clip from the top of Hanging Rock with my iPod Nano. It was a very windy day. The view off the southern side was clear enough that I could see Winston-Salem. What a beautiful experience!

    “The heavens declare the glory of God, and the sky above proclaims his handiwork. Day to day pours out speech, and night to night reveals knowledge.” Psalm 19:1-2

    “For what can be known about God is plain to them, because God has shown it to them. For his invisible attributes, namely, his eternal power and divine nature, have been clearly perceived, ever since the creation of the world, in the things that have been made. So they are without excuse.” Romans 1:19-20

  • test_spec_on_rails now runs on Rails 2.3

    If anyone still happens to be using test_spec, you’ll be thrilled to know that the test_spec_on_rails plugin is now compatible with Rails 2.3. It has also been converted to a gem. Install with:

    sudo gem install test_spec_on_rails
    

    Add to your Rails app’s test.rb like so:

    config.gem 'test_spec_on_rails'
    

    Enjoy the goodness of test-spec helpers from inside your Rails tests. Fork and submit patches via the GitHub project. Tell your friends. Donate money. Vote for Pedro.

  • Processing malformed files with FasterCSV

    On a recent project, I had to implement a CSV parser that would gracefully handle malformed files. I’m talking about files with unescaped quotes, wacky UTF-8 chars, and various other abominations of nature.

    I originally assumed FasterCSV would handle this automagically, but it turns out that the library’s most commonly used methods are pretty strict when it comes to handling CSV files.

    For example, parsing a malformed file one line at a time will result in an exception being thrown, even before any rows are yielded to the block:

    FasterCSV.foreach("malformed.csv") do |row|
      # use row here...
    end
    

    Not cool! I managed to get around this by manually looping over each row and rescuing a malformed CSV exception if one gets thrown:

    FasterCSV.open("malformed.csv", "rb") do |output|
      loop do
        begin
          break unless row = output.shift
          # use row here...
        rescue FasterCSV::MalformedCSVError => e
          # handle malformed row here...
        end
      end
    end
    

    Anyone have a better way to do this?

  • Time warping gem goodness

    The time zone warp code I posted about last week is now a gem:

    sudo gem install time-zone-warp
    

    To configure in your Rails app, add this line to the bottom of test.rb:

    config.gem 'time-zone-warp', :lib => 'time_zone_warp'
    

    You can also fork the code from the project on GitHub.

  • Time zone warp

    One of my Rails projects makes heavy use of time zones. I’ve run into some issues writing good tests for this type of thing. In particular, I’ve needed my tests to run within a time zone outside my own. But I don’t want to permanently change the time zone within the scope of the entire test run. I ended up coding this handler:

    module ZoneWarp
      def pretend_zone_is(zone)
        original_zone = Time.zone
        begin
          Time.zone = zone
          yield
        ensure
          Time.zone = original_zone
        end
      end
    end
    
    Test::Unit::TestCase.send(:include, ZoneWarp)
    

    Simply stick this code in a file inside your config/initializers directory (or include it from test_helper.rb or spec_helper.rb if you insist on doing it the right way) and you’re all set to write tests like this:

    test "code works in other time zones" do
      pretend_zone_is "Mountain Time (US & Canada)" do
        # assertions go here
      end
    end
    
  • Secrets of Effective Nomading

    “Secrets of Effective Nomading” was a lightning talk I was planning on giving at this year’s Ruby Hoedown. Due to my flight arrangements, however, I was unable to give the talk in person. I made a video recording instead. It’s about six minutes long.

    If you’re not familiar with the concepts behind nomadic programming, you might want to read my introduction before watching the video.

    By the way, the Hoedown itself was fantastic. This is the third year Jeremy has run the conference and the presentations were top-notch. By far the best yet. The venue (the Opryland in Nashville) was also quite pleasant, if a little on the expensive side. The expense was worth it, though, if only to hear Jim Weirich present on a source control system that sounded a lot like Git, but wasn’t!

    And of course, the nearby mall complete with movie theater and Bass Pro Shop was just the icing on the cake. (C’mon Raleigh, when are we gonna get a Bass Pro Shop? Charlotte has one.)

  • Learn about Prawn at raleigh.rb on August 18th

    I’ll be giving a presentation about Prawn at this month’s raleigh.rb meetup. Prawn is a Ruby gem that enables fast PDF generation. It is a dramatic improvement over previous libraries like PDF::Writer. It can be used standalone or inside your Rails applications. The markup is powerful and relatively painless to use. I hope you can join us for the fun on August 18th at Red Hat HQ.

  • BarCampRDU was a rousing success

    BarCampRDU 2009 took place last weekend, and was a rousing success (as usual). I heard several attendees comment that the presentations outdid last year’s camp.

    One of the highlights for me was attending Nathaniel’s talk about startups. It was a longer version of the talk he gave at Ignite which was perfect for me since I was unable to attend Ignite. I was also intrigued by a round-table discussion about developing applications for the Palm Pre. The primary reason I haven’t switched to the iPhone yet is because I adore Sprint’s phenomenal coverage area. I’m not willing to “downgrade” to AT&T at this point. The Pre looks like it could be a nice alternative. The jury is still out though, because Curtis mentioned in a hallway conversation that Sprint is planning on introducing a phone that runs Android later this year. Hmm, decisions, decisions.

    I also really enjoyed catching up with some folks I hadn’t seen in a while. Who says geeks aren’t social? By the end of the day I was pretty worn out from all the “socializing” being done. I made sure to get my own presentation in early though, which was a change from last year. I pitched a talk about nomadic programming and jumped on the first time slot in room E, a favorite. The turnout was much higher than expected. I enjoyed sharing some of my own experiences with nomading and hearing what other people had been up to.

    If you’re not familiar with nomading, my previous post on nomadic programming is a great introduction to the concept. Essentially, it’s the idea that getting out of the house or the office and to a coffee shop or co-working location has numerous benefits, including enhancing your productivity and providing fresh networking opportunities. I shared a few of my favorite nomading locations, including The Wake Zone. I also ran through the inventory of my “go-bag:”

    • Power strip/block w/surge protection
    • Wireless mouse (Bluetooth is ideal)
    • Headset w/boom mic (for Skype and music)
    • EVDO connectivity (Millenicom is my recommendation)
    • Laptop (preferably a Mac!)
    • Cables for connecting to an external monitor
    • Water bottle (keepin’ it cool)

    I do plan on writing a follow-up to my original post about nomadic programming. Expect to see something later in September. Something I think we all should do going forward is communicate our nomading plans via Twitter. Make sure to use the #twitter hashtag when you do. Twitter has been the best way for me to coordinate co-working trips with fellow geeks. Chris has said that there really should be an app that makes this easier. Hmm, interesting idea! Anyone want to run with it?

    By the way, make sure you’re following me on Twitter. C’mon, you know you want to.

    In conclusion, I continue to find BarCamp to be, far from a waste of time, a great way to reconnect with a group of geeks I don’t see very often, and also an invaluable educational resource. I always pick up something new when I attend. And who can resist free T-shirts and food? If you’ve never been to BarCamp before, you should definitely consider subscribing to the blog and attending in 2010. You won’t regret it.

  • Ignite Raleigh

    Ignite Raleigh looks quite interesting. It’s essentially a conference made up entirely of lightning talks. Voting is now taking place on submitted talks. The top 10 will be given on August 5th.

    I submitted a talk titled 3 Secrets to Effective Nomading. Check out the description and, if you feel it’s compelling and would want to hear it, please consider voting for it.

    And by all means, if you have an idea for a talk, submit it!