Ruby one-liners

Posted by chad on October 20, 2008

Dave Thomas has a great list of one-liners that are handy for command line jobs in ruby. Today I needed to setup a cron job to find all backup files that match a specific regular expression and delete them when they are 15 days old. Here’s the way I did it (yes some versions of find can do pretty much the same thing but the version that is on the RedHat server i’m using doesn’t seem to do what I want).

find | sort | ruby -pe 'next unless $_ =~ /MYFILTER/; f=$_.gsub(/n/,"");next unless File.mtime(f) < Time.now - 24*60*60*10;File.delete(f) '

Splitting a BaseCamp account into two separate accounts

Posted by chad on October 20, 2008

I have a number of projects in my BaseCamp account and my main client wants to have a different URL for those projects. Additionally, I was paying for the BaseCamp fees but now I’m going to switch to having him pay directly. So, I want to split the account into two accounts and take some projects into the new account and keep some projects in the old account. I emailed 37signals support and Sara responded promptly with this:

Hi Chad,Unfortunately it’s not possible to transfer data between projects or accounts in Basecamp.

- Sarah

Which leads me to wonder if someone wrote a script using the BaseCamp API to do this?

Obie Fernandez Reveals All the Secrets That Make HashRocket Successful

Posted by chad on October 16, 2008

I talked with Obie’s girlfriend and co-worker at HashRocket, Desi McAdam, and she said he would reveal all their secrets during his closing keynote. He has a lot of good information on running a consulting business on his blog that seems to cover a lot of his material here. A good talk.

  • TAFT- Test All the *** Time
  • Rspec – even show this to your clients to prove that their software works
  • Build the Minimum Viable Product
  • Small Releases
  • Write ‘stories’
    • Turn requirements into stories, called ‘storycarding’
    • It takes 3-5 days to do this
  • Schedule using ‘relative’ units of work
    • Estimate each story
  • Have standup meetings

Open Source Brunettes or GitHub as a repository for non-code resources

Posted by chad on October 16, 2008

Seeing as I have been reporting on other Rails events during the conference, I can’t leave this part out. Rails Summit Latin America has been a test tube mix of skinny geeks and beautiful latin women paid to keep them in line. After 48 hours, one SurgeWorks developer, who asked me not to name him, created an open source project to further study the data. In English the name of the project translates to ‘open source brunettes’, and the git tree has been forked already.

Cucumber – scenario based high level test framework by David Chelimsky

Posted by chad on October 16, 2008

You can’t write taste tests for cucumber flavored pepsi, which incidentally is available only in Japan (of course), but you can write tests with Cucumber, which is a framework created by the maintainer of RSpec, David Chelimsky.

Jay Fields discusses the immaturity of testing

Posted by chad on October 16, 2008

Jay gave a talk on testing in the Ruby/Rails world.

Common test mistakes

  • forgetting tests
  • testing everything
  • custom test cases
  • slow test suites
  • 100% test coverage – that is not the goal

I asked Jay what he thought of autotest, and he said unequivocally that he hates it. “If your tests take less than a second, why do you need it? Just click the button.” I think I disagree, because I don’t remember to click the button, and because i don’t always remember that i just changed something that could have broken something else. I’m often surprised when growl pops up a notification that something is broken.

Jay covered problems and benefits of current testing tools:

Selenium

  • 15 different ways to drive it
  • soo slow
  • large test suites become unmaintainable
  • selenium – best tool for cross browser testing
  • runs against the full stack
  • focus on the five most important selenium tests

Test::Unit

  • no mocking infrastructure built in
  • syntax is ugly. argument with chad fowler on this.
  • extremely developer friendly
  • However, granular defect localization
  • Easy to write

Rspec

  • too much magic
  • false positives/negatives
  • too based on english
  • consistent to mancrest, not ‘principle of least surprise’
  • encourages behavorial testing
  • built in mocking
  • no testing facility is complete without a mocking framework

Two Bleeding Edge Ideas

Synthesis written by George Malamedis
Expectations Gem – gives you a recorder

Solutions for slow tests

  • nulldb
  • unitrecord
  • arbs

JRuby is Just Ruby – Overview from Charles Nutter and Thomas Enebo

Posted by chad on October 16, 2008

Charles and Thomas couldn’t be here in person so they’re skyping and controlling the screen to give an overview with running Ruby on Java. Good talk overall, though slightly marred by skype connection difficulties. One bright spot was the talk was a great advertisement for Yugma – the web conferencing tool that integrates with skype and makes remote screen sharing easier. If you’ve run WebEx a lot, you may want to take a look at Yugma.

  • They gave a good overview of performance in jruby vs just ruby, particularly with the ways the Hotspot VM optimizes Java code.
  • Developers are unaware of how far Java performance has come.
  • The Hotspot VM has had 500 man-years of development
  • JRuby on Rails 2.2 – with threadsafe rails and glassfish shows impressive memory improvements
    • 1000 requests @ 55MB of usage vs 1000 requests @ 233 MB w/Rails 2.0.2

Yummi.us – a channel based messaging platform launched by the Phusion Passenger Team 2

Posted by chad on October 16, 2008

The Phusion Passenger guys (Hongli and Ninh) are speaking right now at Rails Summit Latin America. They just unveiled their ‘surprise announcement’ – a messaging platform that looks like the love child of IRC, Twitter, and Campfire called yummi.us. It’s in private Beta right now, but you can contact Ninh at ninh @ phusion.nl if you want an invite.

  • You can have public and private channels
  • It’s integrated with twitter so updates to yummius will show up on your Twitter feed
  • It has syntax highlighting for most languages so pasted in code will be readable. Support for most of the languages TextMate supports
  • You can attach files – you will have a large amount of storage space but they have not decided how much yet
  • The focus seems to be for developers as there’s a Rails plugin for embedding a channel in your own site, and the ability to lock down the channels means you can use it like Campfire as a collaboration tool.

Chris Wanstrath – let other people do the filtering for you

Posted by chad on October 15, 2008

Chris Wanstrath, one of the authors of github, spoke to end the sessions today.

  • Serious full time projects such as Rubinius and Merb started as side-projects

Started working for trucking logistics company, which had no version control, no configuration, but thought that he could use yaml. But there was no PHP parser for yaml, so he wrote spyk – yaml parser in php. Which helped him get a job at GameSpot, which, with recognition from other side projects, got him a job building Chowhound in Rails.

Get rid of time sinks – stop wasting your time reading RSS

  • take a month off from rss reading
  • let other people do the filtering for you
  • the big stuff will find you

Don’t bother with books on practice and theory

  • apply the Jerry Seinfeld calendar theory
    • just do a little a day
    • you want to see that x in the calendar because you worked on your side project for a while week
  • now you can’t say that you don’t have time because you have plenty of time

You don’t need a good idea

  • play with a new framework, like sinatra, rhino or johnson, or master your editor, etc.
  • vi users, learn why people love something like emacs and use that information against them :)
  • alternatively, do something hard.
  • github started as a side project they worked on, only on sundays.
  • scratch your own itch
  • github took 3 months
  • used github to self-host github and their ‘day job’ git repository.

The People You Meet

Posted by chad on October 15, 2008

You will be the same person in five years as you are today except for the people you meet and the books you read. I can’t remember who said that, but you could describe that sentence as the late 2008 rails community theme (aside from the other ‘will I have a job in 2009′ theme.)

I’ll go back and cover the Chris Wanstrath talk in a bit. Generally I’ve noticed that the topic of the season is brand building. Jay Fields has talked extensively about his efforts and how it lead to a better job with a bigger salary. Chad Fowler talked eloquently about being notable. And ‘Dr Nic’ – Nic Williams – talked about ‘the future you’. The future you who will be thankful that you blogged at work about your code, and invested in an open source library or two, and got feedback on your code. Hyperbolically, Dr. Nic says that it’s worth it, even if you get fired – the future you will be grateful.