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
# load plugin | |
load 'boundary' | |
# Notify boundary with your orgid, apikey | |
boundary.register 'cdd7261592bca18539eae9bb5f1bcfdd', 'f9e6282c4727c5733585a4be86e0f990' |
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 'thread' | |
# This seems to crash 1.8.7 | |
10.times { Thread.new { Queue.new.pop } } | |
Process.waitpid fork { GC.start; puts "In child: #{$$}" } |
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
module Papertrail | |
module Zookeeper | |
module Convenience | |
def assign(key, value, options = {}) | |
set(key, value, options) | |
rescue ZK::Exceptions::NoNode | |
begin | |
create(key, value, options) | |
rescue ZK::Exceptions::NodeExists | |
set(key, value, options) |
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
perform_action -> #<(NewRelic::Agent::Instrumentation::ControllerInstrumentation)#perform_action> | |
perform_action_without_benchmark -> #<(ActionController::Filters::InstanceMethods)#perform_action_without_benchmark> | |
perform_action_without_filters -> #<ActionController::Base#perform_action_without_filters> | |
perform_action_without_flash -> #<(ActionController::Rescue)#perform_action_without_flash> | |
perform_action_without_newrelic_trace -> #<(ActionController::Flash::InstanceMethods)#perform_action_without_newrelic_trace> | |
perform_action_without_rescue -> #<(ActionController::Benchmarking)#perform_action_without_rescue> |
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
# | |
# Ideas stolen from lograge and brought to Rails 2.3 | |
# https://github.com/mattmatt/lograge/blob/master/lib/lograge/log_subscriber.rb | |
# | |
module ImprovedControllerLogging | |
def self.included(base) | |
base.alias_method_chain :log_processing, :fixup | |
base.inject_alias_method_chain :perform_action, | |
:perform_action_with_benchmark, |
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 Module | |
# Use this to replace a method in an alias_method_chain | |
def inject_alias_method_chain(target, method_to_replace, method_to_use) | |
method_instance_to_replace = instance_method(method_to_replace) | |
meths = (private_instance_methods | instance_methods).sort.grep(/^#{target}/) | |
found = meths.detect do |m| | |
m != method_to_replace.to_s && instance_method(m) == method_instance_to_replace | |
end | |
if found | |
alias_method found, method_to_use |
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
module Resque | |
module Plugins | |
# If you want only one instance of your job queued at a time, | |
# extend it with this module. | |
# | |
# For example: | |
# | |
# require 'resque/plugins/zookeeper_lock' | |
# | |
# class UpdateNetworkGraph |
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
# Wrap tasks in exception notification | |
def task(*args, &block) | |
if block | |
wrapper = proc do |*a| | |
begin | |
block.call(*a) | |
rescue Interrupt, SignalException, SystemExit | |
raise | |
rescue Exception => e | |
Papertrail::ExceptionNotifier.notify(e) rescue nil |
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 ActionController::TestCase | |
def assert_select_with_silence_warnings(*args) | |
silence_warnings do | |
assert_select_without_silence_warnings(*args) | |
end | |
end | |
alias_method_chain :assert_select, :silence_warnings | |
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
class MultiTimer | |
def initialize(*timers) | |
@timers = [] | |
add_timer(*timers) | |
end | |
def time(callable = nil, &block) | |
callable ||= block | |
context = Metriks::Timer::Context.new(self) |