This file contains hidden or 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
| key = 'queue:default' | |
| if Resque.redis.exists(key) | |
| members = Resque.redis.lrange(key, 0, -1) | |
| duplicate_members = members.group_by { |e| JSON.parse(e)["args"][0].except("job_id").to_s }.select { |k, v| v.size > 1 }.map{ |a| a[1].drop(1) }.flatten | |
| duplicate_members.each do |duplicate_member| | |
| Resque.redis.lrem(key, -1, duplicate_member) | |
| end | |
| end |
This file contains hidden or 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
| /sbin/ifconfig en0 | grep 'inet ' | cut -d: -f2 | awk '{ print $2}' |
This file contains hidden or 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
| ages = { "Bruce" => 32, "Clark" => 28 } | |
| mappings = {"Bruce" => "Bruce Wayne", "Clark" => "Clark Kent"} | |
| Hash[ages.map {|k, v| [mappings[k], v] }] |
This file contains hidden or 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
| Redirect stdout and stderr to a variable (so you can handle an error without printing to the console) | |
| ERROR_MSG=$(redis-cli PING 2>&1) | |
| Redirect only stdout to a variable | |
| ERROR_MSG=$(redis-cli PING) | |
| Redirect a whole block of commands to not print | |
| { | |
| ERROR=$(redis-cli PING) | |
| } >/dev/null 2>&1 |
This file contains hidden or 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
| function iOSversion() { | |
| if (/iP(hone|od|ad)/.test(navigator.platform)) { | |
| var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/); | |
| return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)]; | |
| } | |
| } |
This file contains hidden or 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
| heroku run "bundle exec rake db:schema:dump && cat db/schema.rb" | |
| heroku run rake db:schema:load |
This file contains hidden or 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_INDEX_FILE=some-non-existent-file \ | |
| git ls-files --exclude-standard --others --directory --ignored -z) | | |
| xargs -0 git rm --cached -r --ignore-unmatch -- |