Skip to content

Instantly share code, notes, and snippets.

View zanker's full-sized avatar

Zachary Anker zanker

  • San Francisco, CA
View GitHub Profile
class Person
include Mongoid::Document
field :name, :type => String
embeds_one :location
end
class Location
include Mongoid::Document
field :country, :type => String, :default => "US"
field :address, :type => String
@zanker
zanker / gist:3231660
Created August 1, 2012 23:53
Example of aws-security-group-manager file
ec2:
default:
-
group: monitor
region: us-west-1
port: 4949
protocol: tcp
note: M/Monit
-
group: monitor
@zanker
zanker / gist:5351986
Created April 10, 2013 05:12
Modification of the original Mongo instrumentation by Alexey Palazhchenko. This handles obfuscating values itself which means Newrelics obfuscator should be set to raw to prevent it breaking anything. This will also make Mongo show up under the overview again.
DependencyDetection.defer do
@name = :mongodb
depends_on do
defined?(::Mongo) and not NewRelic::Control.instance['disable_mongodb']
end
executes do
NewRelic::Agent.logger.debug 'Installing MongoDB instrumentation'
end
require 'benchmark'
require 'protobuf'
require 'varint/varint'
ITERATIONS = 1_000_000
class Test
extend ::Varint
@zanker
zanker / protobuf-benchmark.rb
Created November 10, 2015 21:44
Benchmark of various Ruby protocol buffer libraries.
require 'benchmark'
require 'beefcake' # 1.1.0
require 'protocol_buffers' # 1.6.1
require 'protobuf' # 3.5.5
require 'protobuf/message'
require 'google/protobuf' # 3.0.0.alpha.4.0
require 'varint/varint' # 0.1.1
module Test
# beefcake
@zanker
zanker / benchmark-protobuf.rb
Last active November 10, 2015 21:51
Benchmark results of protobuf vs google-protobuf gems
=begin
Decoding a large proto 1,000 times.
Ruby 2.2.3
user system total real
protobuf encoding 13.060000 0.180000 13.240000 ( 13.262584)
google-protobuf encoding 1.780000 0.050000 1.830000 ( 1.823272)
protobuf decoding 8.890000 0.030000 8.920000 ( 8.927971)
@zanker
zanker / gist:5278a25a2904f7542150
Created March 11, 2016 21:59
raven-ruby optimizations
Measure Mode: wall_time
Thread ID: 70319499115040
Fiber ID: 70319529395800
Total Time: 1.1018621921539307
Sort by: total_time
%total %self total self wait child calls Name
--------------------------------------------------------------------------------
100.00% 0.00% 1.102 0.000 0.000 1.102 1 Global#[No method]
1.102 0.001 0.000 1.100 1/1 Integer#times
@zanker
zanker / gist:683c9346af06453a8b14
Created March 11, 2016 21:59
raven-ruby base
Measure Mode: wall_time
Thread ID: 70262938909220
Fiber ID: 70262945578140
Total Time: 12.474074363708496
Sort by: total_time
%total %self total self wait child calls Name
--------------------------------------------------------------------------------
100.00% 0.00% 12.474 0.000 0.000 12.474 1 Global#[No method]
12.474 0.002 0.000 12.472 1/1 Integer#times
@zanker
zanker / nginx.conf
Last active November 23, 2017 14:51
daemon off;
worker_processes 1;
error_log /dev/stdout debug;
pid /tmp/nginx.pid;
events {
worker_connections 8192;
}
require 'http'
started_at = Time.now
threads = 10.times.map do |i|
sleep 0.1
Thread.new do
begin
started_at = Time.now
response = HTTP.get("http://localhost:8001/#{i}")