Pages
Categories
Archives
- February 2012
- January 2012
- December 2011
- November 2011
- November 2010
- March 2010
- January 2010
- December 2009
- November 2009
- August 2009
- July 2009
- June 2009
- February 2009
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- November 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
Category Archives: Snippets
Snippet: ls_r (recursively list and process directories)
Here’s a little Ruby function I came up with today. I thought it might be useful to other people, so here it is. Think you can do better? Fork me and prove it! ;)
Also posted in Ruby Leave a comment
Snippet: Hash#with_only, #merge_existing
Here are some potentiall useful one-liner methods for extracting and merging only parts of Hashes. I was surprised to find out that Hash didn’t already have built-in methods to do these things. Maybe they’re considered so obvious that they don’t need to be built-in, but I think the readability gain is worth it. 1 2 [...]
Snippet: Range#compare
Here’s a little idea that popped into my head for enhancing the Range class in Ruby: 1 2 3 4 5 6 7 8 9 10 11 class Range def compare( value ) if member?( value ) 0 elsif value <= self.begin -1 elsif value >= self.end 1 end end end Then you can perform [...]
Sup email client keybindings and filters