Eric Lindvall eric

View redis_failover.rake
1 2 3 4 5 6 7 8 9 10
namespace :redis_failover do
task :monitor_client do
require 'redis_failover'
 
zookeepers = ENV['ZOOKEEPERS']
 
if !zookeepers && zookeepers_file = ENV['ZOOKEEPERS_FILE']
if File.exists?(zookeepers_file)
zookeepers = File.read(zookeepers_file).chomp
end
View librato_metric.rb
1 2 3 4 5 6 7 8 9 10
require 'lazy'
require 'system_timer'
 
class LibratoMetric
COUNT = 10
RESOLUTION = 1
 
def initialize(metric_name, timeout = 4)
@metric_name = metric_name
@timeout = timeout
View jobs.rb
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/env ruby
# encoding: utf-8
 
# setup
#
require 'fileutils'
 
script = File.expand_path(__FILE__).gsub(%r|\breleases/\d+\b|, 'current')
script_dir = File.dirname(script)
rails_root = File.dirname(script_dir)
View boundary_client.rb
1 2 3 4 5 6 7 8 9
#
# Simple Boundary client
#
 
class BoundaryClient
def initialize(orgid, apikey)
@orgid = orgid
@apikey = apikey
end
View cubism.papertrail.js
1 2 3 4 5 6 7 8 9 10
/*
* Cubism source for Papertrail
* https://papertrailapp.com/
*/
 
cubism.context.prototype.papertrail = function(token) {
var source = {};
 
source.metric = function(expression, title) {
var lookup = {};
View _deploy.rb
1 2 3 4 5
# load plugin
load 'boundary'
 
# Notify boundary with your orgid, apikey
boundary.register 'cdd7261592bca18539eae9bb5f1bcfdd', 'f9e6282c4727c5733585a4be86e0f990'
View crash_a_187.rb
1 2 3 4 5
require 'thread'
 
# This seems to crash 1.8.7
10.times { Thread.new { Queue.new.pop } }
Process.waitpid fork { GC.start; puts "In child: #{$$}" }
View convenience.rb
1 2 3 4 5 6 7 8 9 10
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)
View gist:2581994
1 2 3 4 5 6
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>
View improved_controller_logging.rb
1 2 3 4 5 6 7 8 9 10
#
# 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,
Something went wrong with that request. Please try again.