John Baylor experiments

irb Tip

Have you ever loaded a file into irb, only to find that it scrolls endlessly? Its easy to do by accident:

log = File.open('bigger_file_than_you_expected.log') { |f| f.read }

But a simple trick can limit the output to a single useful line:

(log = File.open('bigger_file_than_you_expected.log') { |f| f.read }).length
=> 5066612

Now you can happily slice and dice your data without all the useless output.  And yes, it applies to any operation that would spit out more data than you really want to see.

Blog format shamelessly lifted from Mojombo, creator of Jekyll