This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ok, so I'm trying to replace a ' character with \' in a ruby string. I have working code, but it was | |
*way* too painful getting there for my taste. | |
Take a look: | |
ree-1.8.7-2010.02 :001 > single_quote = "\'" | |
=> "'" | |
ree-1.8.7-2010.02 :003 > single_quote.gsub(/'/, "\\\'") | |
=> "" | |
ree-1.8.7-2010.02 :004 > single_quote.gsub(/'/) {|c| "\\'"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn recursive-reverse [coll] | |
(if (= 0 (count coll)) | |
[] | |
(concat (recursive-reverse (drop 1 coll)) (take 1 coll)))) | |
(defn recursive-reverse [coll] | |
(loop [coll coll | |
acc []] | |
(if (empty? coll) | |
acc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl http://url-to-hudson-log | grep -A 5 'Failing Scenarios' | grep ^cucumber | awk '{print $2}' | sed -e 's/^.*\(\/features.*\)$/\1/' | sed -e 's/^.//' | xargs script/cucumber |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git grep 'thing_to_search_for' | grep spec | grep -v vendor | grep rb: | awk '{print $1}' | sed -e 's/.$//' | uniq | xargs spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -type f -name \*.rb -exec grep -qi "foo" {} \; -print |xargs sed -i "" -e "s|foo|bar|g" -e "s|Foo|Bar|g" |
NewerOlder