Skip to content

Instantly share code, notes, and snippets.

@eric
eric / copy_librato_dashboard.rb
Last active July 15, 2016 22:11 — forked from jderrett/copy_librato_dashboard.rb
Copy Librato Dashboard from one account to another
require 'faraday'
require 'faraday_middleware'
require 'json'
class DashboardApi
LIBRATO_API = 'https://metrics-api.librato.com'
LIBRATO_API_VERSION = 'v1'
ENDPOINT = [LIBRATO_API, LIBRATO_API_VERSION].join('/')
attr_accessor :username
package main
import (
"testing"
"sync"
"sync/atomic"
)
func TestOneBarrier(t *testing.T) {
expected := int32(2)
@eric
eric / jobs.rb
Created July 16, 2012 19:17 — forked from ahoward/jobs.rb
./script/jobs
#!/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)
@eric
eric / connection_fix.rb
Created August 3, 2011 23:56 — forked from defunkt/connection_fix.rb
MySQL server has gone away fix
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
@eric
eric / gist:1079424
Created July 12, 2011 23:32 — forked from jnunemaker/fu.md
FUN BUG?!

Posted to the REE Google Group as well: https://groups.google.com/forum/#!topic/emm-ruby/EBkMfFpk40A

A week back I innocently updated Sinatra on an app which in turn updated Rack. Since then, I've had crazy hung passenger processes that just gobble up CPU like it is going out of style.

After spending a few days trying everything I knew to to fix it, today I got help from a friend (Eric Lindvall) and dug in with strace, rbtrace, gdb, and gdb.rb and found the issue. Rack 1.3.0 tests a regex against a URL and it causes things to hang.

@eric
eric / README.md
Created June 20, 2011 23:50 — forked from mheffner/README.md
Setting up syslog logging on Heroku with Sinatra 1.2.x

Setting up syslog logging on Heroku with Sinatra 1.2.x

1. Update your Gemfile to include:

gem 'remote_syslog_logger'

3. Modify your config.ru to match the example one below.

4. Setup REMOTE_SYSLOG_URI environment variable

@eric
eric / wtf.rb
Created June 8, 2011 05:11 — forked from dbalatero/wtf.rb
# A little helper from _why
class Object
def metaclass
class << self; self; end
end
end
module A
def self.foo
puts "yes"
@eric
eric / SAFE-RUBY.rb
Created February 16, 2011 06:24 — forked from holman/SAFE-RUBY.rb
require 'net/https'
require 'always_verify_ssl_certificates'
module SecurityModule
class HighSecurity
class ReallyHighSecurity
def self.turn_on_safe_connections
OpenSSL::SSL::VERIFY_NONE
end
end
@eric
eric / gist:718455
Created November 28, 2010 00:59 — forked from catlike/gist:718450
require 'rubygems'
require 'sinatra'
require 'lib/sms'
require 'thread'
SECONDS_PER_MESSAGE = 1.0
queue = Queue.new
consumer = Thread.new do
@eric
eric / gist:625913
Created October 14, 2010 09:03 — forked from rtomayko/gist:625807
This time bay-beee I'll beeeeeeEEEEEEEEEeeeee - BullehhhhhhhhhhhhhhhT PROOOF.
This time may-beee I'll beeeeeeeeeee... Bulleeeeeht proof.