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
| #!/bin/bash | |
| # Also see: http://vitobotta.com/resque-automatically-kill-stuck-workers-retry-failed-jobs/ | |
| [[ -f /tmp/retry-failed-resque-jobs ]] && rm /tmp/retry-failed-resque-jobs | |
| ps -eo pid,command | | |
| grep [r]esque | | |
| grep "Processing" | | |
| while read PID COMMAND; do |
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
| $ bundle exec scripts/upload-dist.rb | |
| opening connection to api.github.com... | |
| opened | |
| <- "POST /repos/concord-consortium/lab/downloads HTTP/1.1\r\nAuthorization: Basic c3RlcGhlbmViOm4wMGRsZQ==\r\nConnection: close\r\nHost: api.github.com\r\nContent-Length: 147\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n" | |
| <- "{\"name\":\"lab-dist-2012-03-24-e5ce60c.tar.gz\",\"size\":9433478,\"description\":\"Latest release of Lab distribution\",\"content_type\":\"application/x-gzip\"}" | |
| -> "HTTP/1.1 201 Created\r\n" | |
| -> "Server: nginx/1.0.13\r\n" | |
| -> "Date: Sun, 25 Mar 2012 18:19:18 GMT\r\n" | |
| -> "Content-Type: application/json; charset=utf-8\r\n" | |
| -> "Connection: close\r\n" |
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
| # Originally from http://bit.ly/GIhZmg | |
| # modified by @colour to reflect locations of assets in the asset pipeline | |
| namespace :spec do | |
| desc "Add files that DHH doesn't consider to be 'code' to stats" | |
| task :statsetup do | |
| require 'rails/code_statistics' | |
| class CodeStatistics | |
| alias calculate_statistics_orig calculate_statistics |
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
| require 'new_relic' | |
| require 'faraday' | |
| require 'active_support' | |
| class InstrumentationMiddleware < Faraday::Middleware | |
| extend NewRelic::Agent::MethodTracer | |
| def call(env) | |
| uri = env[:url] | |
| method = env[:method] | |
| metrics = ["External/#{uri.host}/Faraday/#{method}", "External/#{uri.host}/all"] |
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
| #!/usr/bin/env ruby | |
| # -*- encoding: UTF-8 -*- | |
| # Derived from <http://stackoverflow.com/questions/5663519/namespacing-thor-commands-in-a-standalone-ruby-executable> | |
| require 'rubygems' | |
| require 'thor' | |
| require 'thor/group' | |
| module Hammer |
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
| $ ./executable-with-subcommands-using-thor.rb | |
| Tasks: | |
| executable-with-subcommands-using-thor.rb help [TASK] # Describe available tasks or one specific task | |
| executable-with-subcommands-using-thor.rb subA [TASK] # Execute a task in namespace subA | |
| executable-with-subcommands-using-thor.rb subB [TASK] # Execute a task in namespace subB | |
| executable-with-subcommands-using-thor.rb test # test in CLI | |
| $ ./executable-with-subcommands-using-thor.rb help | |
| Tasks: | |
| executable-with-subcommands-using-thor.rb help [TASK] # Describe available tasks or one specific task |
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
| # pm - Print methods of objects in irb/console sessions. | |
| # Goes in ~./irbrc | |
| # | |
| begin # Utility methods | |
| def pm(obj, *options) # Print methods | |
| methods = obj.methods | |
| methods -= Object.methods unless options.include? :more | |
| filter = options.select {|opt| opt.kind_of? Regexp}.first | |
| methods = methods.select {|name| name =~ filter} if filter |