Category Archives: Snippets

Sup email client keybindings and filters

Lately I’ve been playing with Sup, a geeky console-based email client written in Ruby. I’ve used it enough to understand it and settle in a bit, but unfortunately also enough to realize that it’s probably not right for me. Along the way, though, I’ve done some work with keybindings and message filters that I’d like [...]

Also posted in Ruby | Tagged , | 2 Comments

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 [...]

Also posted in Ruby | Tagged , | 2 Comments

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 [...]

Also posted in Ruby | Tagged , , , | Leave a comment