Interesting Things
- silly Ruby trick of the day — does anyone know what this does?
while gets print if /foo/ end
This is an example from the Ruby “Pickaxe” book. No respected Rubyist actually writes such difficult-to-understand and obfuscated code. Though, it was mentioned, that terse syntax like this is useful for command-line hacking.
unstub!is a useful Rspec method that removes a stub from a previously stubbed object. This can be useful if you have stubbed, then mocked the same method, and you want to remove the stub.The unofficial community-developed iPhone app for Pivotal Tracker, is changing its name from iPivotal to PTCruiser. See the author’s Twitter for more.
It does the same thing as
ruby -ne ‘print if /foo/’
which does the same thing as
egrep foo
If you’re a Perl refugee, this isn’t particularly obfuscated. And
ruby -n00e ‘print if /foo/’ some-file.ldif
will print the complete, multi-line text of every entry in the LDIF file that contains “foo”, which I don’t know how to do with grep or egrep.
September 17, 2009 at 10:54 am