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
a = Hash.new | |
a['key1'] = 'one' | |
a['key0'] = 'zero' | |
a.each_value do |value| | |
puts value | |
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
~/Dropbox/Projects/prospectsearch/prospectsearch(master ✗) rake spec | |
rake aborted! | |
undefined method `[]' for nil:NilClass | |
/Users/lang/.rvm/gems/ruby-1.9.3-p385@prospectsearch/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:525:in `block (3 levels) in <top (required)>' | |
/Users/lang/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.4/lib/rake/task.rb:246:in `call' | |
/Users/lang/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute' | |
/Users/lang/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.4/lib/rake/task.rb:241:in `each' | |
/Users/lang/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute' | |
/Users/lang/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain' | |
/Users/lang/.rvm/gems/ruby-1.9.3-p385@global/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain' |
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 Derp | |
def self.do_the_thing(param) | |
new(param).do_the_thing | |
end | |
def do_the_thing(param) | |
# Actually does the thing | |
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
# Number of documents in an index | |
curl -s http://localhost:9200/test_volunteering_entities/_stats/docs | jq '._all.total.docs.count' | |
# First ten items in an index | |
curl -s http://localhost:9200/development_charities/_search?size=10 | jq '.hits.hits[] | ._source.name' |
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
https://github.com/soundcloud/lhm/blob/master/lib/lhm.rb#L45 | |
https://github.com/soundcloud/lhm/blob/master/lib/lhm/invoker.rb#L43 | |
https://github.com/soundcloud/lhm/blob/master/lib/lhm/entangler.rb |
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
# > ProgressCountDown.new.call { Model.where(state: [:pending, :waiting]).count } | |
# Things: |============== | (30693/224796) ETA: 03:37:1 | |
class ProgressCountDown | |
def call | |
total = yield | |
progress = | |
ProgressBar.create( | |
title: "Things", | |
total: total, |
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
set -e # Exit immediately if a command exits with a non-zero status | |
set -u # Exit immediately if an undefined variable is used (e.g. echo "$UNDEFINED_ENV_VAR") | |
set -o pipefail # Ensures pipelines (e.g. cmd | othercmd) return a non-zero status if a command fails | |
set -x # Print each expanded command before executing (useful for debugging) | |
# Source: https://buildkite.com/docs/guides/writing-build-scripts |
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
# Dump into a "custom" compressed format | |
pg_dump -Fc db_name > db_name.dump |
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
$ bundle exec sidekiq | |
m, | |
`$b | |
.ss, $$: .,d$ | |
`$$P,d$P' .,md$P"' | |
,$$$$$bmmd$$$P^' | |
.d$$$$$$$$$$P' | |
$$^' `"^$$$' ____ _ _ _ _ |
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
# The one you want is | |
def method | |
string = <<~END | |
This format allows you to indent the contents of the string without including the indent in the value. | |
String interpolation works here. | |
END |
OlderNewer