Example reference-style link across newlines.
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
# which is the correct return value? | |
{ :a => 1, :b => 2 }.fetch(:a, :b) # => [ 1, 2 ] | |
{ :a => 1, :b => 2 }.fetch(:a, :b) # => :b |
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 branch -r | while read BRANCH; do | |
if [ `git incoming $BRANCH | wc -l` != 0 ]; then | |
AUTHOR=`git log $BRANCH -n 1 --format=format:%ae` | |
MESSAGE="You appear to be the person responsible for \`$BRANCH\`. It has unmerged commits. Can you take a second take make sure you still need it? If so, merge it when you can. If not, do a \`git push origin :${BRANCH#origin/}\`. Thanks." | |
echo -e $MESSAGE | mail -s "Possible stale branch" $AUTHOR | |
fi | |
done |
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 branch -r | while read BRANCH; do | |
if [ `git incoming $BRANCH | wc -l` == 0 ]; then | |
echo $BRANCH | |
fi | |
done |
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
Stage this hunk [y,n,q,a,d,/,k,K,g,e,?]? @@ -48 +81,2 @@ | |
end | |
\ No newline at end of file | |
Stage this hunk [y,n,q,a,d,/,k,K,g,e,?]? @@ -48 +81,2 @@ | |
end | |
\ No newline at end of file | |
Stage this hunk [y,n,q,a,d,/,k,K,g,e,?]? @@ -48 +81,2 @@ | |
end | |
\ No newline at end of file | |
Stage this hunk [y,n,q,a,d,/,k,K,g,e,?]? @@ -48 +81,2 @@ |
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
def decode_transloadit_json | |
return unless params[:transloadit].present? | |
# wrap transloadit params in a HashWithIndifferentAccess | |
params[:transloadit] = ActiveSupport::HashWithIndifferentAccess.new( | |
ActiveSupport::JSON.decode params[:transloadit] | |
) | |
# decode parameters from transloadit | |
params[:transloadit][:uploads].first.tap do |history| |
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
class Foo | |
autoload :Bar, 'foo/bar' | |
autoload :Baz, 'foo/baz' | |
end |
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
def join(*args) | |
args.unshift self | |
result = args.pop | |
result = Pathname.new(result) unless Pathname === result | |
return result if result.absolute? | |
args.reverse_each {|arg| | |
arg = Pathname.new(arg) unless Pathname === arg | |
result = arg + result | |
return result if result.absolute? | |
} |
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
def purge_if | |
self.inject({}) do |hash, (key, value)| | |
yield(key, value) ? hash : hash.update(key => self.delete(key)) | |
end | |
end |
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
require 'active_support/concern' | |
module Hash::PurgeIf | |
include ActiveSupport::Concern | |
included do |base| | |
raise 'Hash#purge_if already defined' if | |
base.instance_methods.include?(:purge_if) | |
end | |