Skip to content

Instantly share code, notes, and snippets.

View justindossey's full-sized avatar

Justin Dossey justindossey

  • Laudable Labs
  • San Francisco, CA
View GitHub Profile
@justindossey
justindossey / gist:2255384
Created March 30, 2012 21:40
Flip read_secondary via MongoMapper
trap('USR2') do
# reconnect to MongoDB with read_secondary reversed
result=MongoMapper.connection.instance_eval('@read_secondary = !@read_secondary')
logger.notice("#{Time.now}: now reading from #{result ? 'secondary' : 'primary'}")
end
@justindossey
justindossey / gist:7490942
Last active December 28, 2015 11:08
ruby 187 memory leak with logger in Bunny::Queue#subscribe
require 'bunny'
require 'logger'
class TestLoggerSubscribeMemleak
def initialize(msg_count=10_000)
@message_count = msg_count
@messages_to_write = msg_count
@connection = Bunny.new(:user=>"test_user", :pass=>"123456", :host=>"localhost", :vhost => "test", :port => 5672)
@connection.start
@channel = @connection.create_channel
@justindossey
justindossey / test_fd_subscribe_memleak.rb
Created November 15, 2013 20:33
Non-leaking version of bunny logger memory leak test
require 'bunny'
require 'logger'
class TestLoggerSubscribeMemleak
def initialize(msg_count=10_000)
@messages_to_write = msg_count
@message_count = msg_count
@connection = Bunny.new(:user=>"jbd_dev_reader", :pass=>"123456", :host=>"localhost", :vhost=>"jbd", :port=>5672)
@connection.start
@channel = @connection.create_channel
@justindossey
justindossey / serial.pp
Created January 4, 2017 19:52
custom fact with defined type
# Configure a serial port for IPMI (which provides virtual ones).
# Depends on the "serial_ports" custom fact, included in this module
define ipmi::serial {
include stdlib
include ipmi::serial_prerequisites
$port_exists = member($::serial_ports, "/dev/${title}")
if $port_exists {
service { $title:

Keybase proof

I hereby claim:

  • I am justindossey on github.
  • I am jbd (https://keybase.io/jbd) on keybase.
  • I have a public key ASAoh5-1psnhAkvJuhXxjUToBfwnloUfF9-Xn3SGy7eJhgo

To claim this, I am signing this object: