Skip to content

Instantly share code, notes, and snippets.

View mperham's full-sized avatar

Mike Perham mperham

View GitHub Profile
@mperham
mperham / gist:5050311
Created February 27, 2013 18:31
monit causes memcached performance issues
--- a/site-cookbooks/monit/templates/default/memcached.conf.erb
+++ b/site-cookbooks/monit/templates/default/memcached.conf.erb
@@ -2,5 +2,5 @@ check process memcached
with pidfile /var/run/memcached.pid
start program = "/etc/init.d/memcached start"
stop program = "/etc/init.d/memcached stop"
- if failed port 11211 protocol memcache 4 times within 6 cycles then restart
+ if failed port 11211 4 times within 6 cycles then restart
if 5 restarts within 5 cycles then timeout
1 (M=55122) ~/src/theclymb> rvm info
ruby-1.9.3-p125@theclymb3:
system:
uname: "Darwin Mikes-MacBook-Air.local 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64"
system: "osx/10.8/x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)"
zsh: "/bin/zsh => zsh 4.3.11 (i386-apple-darwin12.0)"
@mperham
mperham / gist:4012475
Created November 4, 2012 16:22
2.0.0.rc1 crash
.FF..........................................................................................................................................................................................................
---------------------------------------------
CRASH: A fatal error has occurred.
Backtrace:
0 rbx 0x000000010c04f6d0 _ZN8rubiniusL12segv_handlerEi + 544
1 libsystem_c.dylib 0x00007fff91c31cfa _sigtramp + 26
2 libsystem_c.dylib 0x00007fff91c2f3c8 malloc_zone_malloc + 77
3 rbx 0x000000010c16a202 _ZN8rubinius12CompiledCode4Info4markEPNS_6ObjectERNS_10ObjectMarkE + 318
4 rbx 0x000000010c20075e _ZN8rubinius16GarbageCollector11scan_objectEPNS_6ObjectE + 456
@mperham
mperham / gist:3988273
Created October 31, 2012 16:56
1.9.3-p125 vs 1.9.3-p286-falcon
(speedup_rails_startup=fa456 .rvmrc bin/) ~/src/clymb> !time
time bundle exec rake environment
real 0m7.853s
user 0m6.485s
sys 0m1.129s
(speedup_rails_startup=fa456 .rvmrc bin/) ~/src/clymb> time bundle exec rake environment
real 0m7.478s
user 0m6.378s
@mperham
mperham / retries.rb
Created October 19, 2012 22:15
Sidekiq retry management API
require 'sidekiq'
module Sidekiq
# Encapsulates a single job awaiting retry
class Retry
attr_reader :score, :item
def initialize(score, item)
@score = score
@item = Sidekiq.load_json(item)
@mperham
mperham / gist:3667520
Created September 7, 2012 16:20
Campfire in 10 lines
##
# Broadcast a message to Campfire
#
# campfire = Campfire.new(options)
# campfire.say("#{self.class.name} finished successfully!")
# campfire.say("trombone", :Sound)
#
def say(msg, type=:Text)
http = Net::HTTP.new("#{options[:subdomain]}.campfirenow.com", 443)
http.use_ssl = true
@mperham
mperham / gist:3651105
Created September 6, 2012 04:11
Campfire's SSL cert doesn't verify with Ruby 1.9.3 p194
# This works for me in 1.9.3-p125 but not in p194.
# Can anyone explain why?
require 'net/http'
http = Net::HTTP.new("theclymb1.campfirenow.com", 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
request = Net::HTTP::Get.new("/login")
response = http.request(request)
raise response.inspect if response.code != '200'
@mperham
mperham / after.rb
Created July 4, 2012 19:30
Thread-friendly shared connection
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || ConnectionPool::Wrapper.new(:size => 1) { retrieve_connection }
end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
@mperham
mperham / gist:2485051
Created April 25, 2012 00:58
YAML parsing bug in Ruby 1.9.3?
YAML.parse(BELOW) fails, I believe due to the shipCompany line below which contains a single backtick.
```
--- !ruby/object:Delayed::PerformableMethod
args: []
method_name: :push_to_wh
object: !ruby/ActiveRecord:Cart
attributes:
split_to:
DEPRECATION WARNING: Layout found at "admin/customer_service" for Admin::CustomerServiceController but parent controller set layout to "admin/customer_service". Please explicitly set your layout to "admin/customer_service" or set it to nil to force a dynamic lookup. (called from realtime at /Users/mperham/.rvm/rubies/ree-1.8.7-2012.02/lib/ruby/1.8/benchmark.rb:308)