Skip to content

Instantly share code, notes, and snippets.

@grantr
grantr / sax_test.rb
Created March 22, 2012 17:17
saxaphone bug?
require 'rubygems'
require 'saxaphone'
require 'stringio'
class Location < Saxaphone::Element
has_element 'categories', 'Categories' do |element|
puts "categories element #{element.categories.inspect}"
attributes['categories'] = element.categories
end
end
@grantr
grantr / sax_test2.rb
Created March 23, 2012 00:11
saxaphone bug take 2
require 'rubygems'
require 'saxaphone'
require 'stringio'
class Location < Saxaphone::Element
has_element 'categories', 'Categories' do |element|
puts "categories element #{element.categories.inspect}"
attributes['categories'] = element.categories
end
end
module Zensu
module RPC
class Requester
include Celluloid::ZMQ
include RPC::Encoding
def initialize
@socket = Celluloid::ZMQ::ReqSocket.new
begin
@grantr
grantr / zeromq.rb
Created June 5, 2012 18:37
finalizer or at_exit
require 'cabin'
require 'ffi-rzmq'
class Cabin::Outputs::ZeroMQ
DEFAULTS = {
:topology => "pushpull",
:hwm => 0, # default: no limit
:linger => -1 # default: wait until all messages are sent
}
@grantr
grantr / sensu_standalone_check.rb
Created July 13, 2012 19:32
standalone sensu check chef definition
# installs a standalone sensu check
# sensu_standalone_check "unicorn_master" do
# command "#{node.sensu.directory}/plugins/processes/check-procs.rb"
# arguments "-f #{deploy_to}/shared/pids/unicorn.pid"
# end
define :sensu_standalone_check, :interval => 60, :enable => true, :owner => "root", :mode => 0644 do
include_recipe "sensu::_config"
@grantr
grantr / gist:3166617
Created July 23, 2012 22:22
ffi-rzmq segfault
/us/apps/rails_app/shared/bundle/ruby/1.9.1/gems/ffi-rzmq-0.9.3/lib/ffi-rzmq/socket.rb:189: [BUG] Segmentation fault
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0075 p:---- s:0265 b:0265 l:000264 d:000264 CFUNC :zmq_connect
c:0074 p:0022 s:0260 b:0260 l:000259 d:000259 METHOD /us/apps/rails_app/shared/bundle/ruby/1.9.1/gems/ffi-rzmq-0.9.3/lib/ffi-rzmq/socket.rb:189
c:0073 p:0015 s:0255 b:0254 l:000245 d:000253 BLOCK /us/apps/rails_app/shared/bundle/ruby/1.9.1/gems/tracer5-0.1.2/lib/tracer5/subscriber/zmq_output.rb:16
c:0072 p:---- s:0251 b:0251 l:000250 d:000250 FINISH
c:0071 p:---- s:0249 b:0249 l:000248 d:000248 CFUNC :each
c:0070 p:0149 s:0246 b:0246 l:000245 d:000245 METHOD /us/apps/rails_app/shared/bundle/ruby/1.9.1/gems/tracer5-0.1.2/lib/tracer5/subscriber/zmq_output.rb:15
@grantr
grantr / reel_app.rb
Created August 23, 2012 22:48
Reel-powered http endpoints
require 'octarine'
require 'reel'
module Reel
module App
def self.included(base)
base.class_eval do
include Octarine::App
attr_accessor :server
@grantr
grantr / reel_chunked_test.rb
Created August 29, 2012 23:58
Reel chunked-encoding bug
require 'reel'
connections = []
server = Reel::Server.supervise '0.0.0.0', 3012 do |connection|
if request = connection.request
connections << connection
connection.respond :ok, transfer_encoding: :chunked
end
end
@grantr
grantr / waiting.wsp.dump
Created October 4, 2012 16:46
Whisper dump
Meta data:
aggregation method: average
max retention: 63072000
xFilesFactor: 0.5
Archive 0 info:
offset: 52
seconds per point: 10
points: 2160
retention: 21600
@grantr
grantr / gist:4074383
Created November 14, 2012 19:57
rabbitmqctl environment
Application environment of node sensu1@sensu1 ...
[{auth_backends,[rabbit_auth_backend_internal]},
{auth_mechanisms,['PLAIN','AMQPLAIN']},
{backing_queue_module,rabbit_variable_queue},
{cluster_nodes,[]},
{collect_statistics,fine},
{collect_statistics_interval,5000},
{default_permissions,[<<".*">>,<<".*">>,<<".*">>]},
{default_user,<<"guest">>},
{default_user_tags,[administrator]},