Skip to content

Instantly share code, notes, and snippets.

Notifo notifier

Send yourself a notification with:

$ notifo --user myself --token c01e66f7c7ebb828cd8f59282a3c6c18 'The job is done'

Don't worry about remembering your token:

$ echo "NOTIFO_USER=myself" >> ~/.notifo_credentials

$ echo "NOTIFO_TOKEN=c01e66f7c7ebb828cd8f59282a3c6c18" >> ~/.notifo_credentials

Name : librato-silverline
Version : 3.1.3
Release : 1
Architecture: i386
Install Date: Fri 05 Aug 2011 10:50:07 AM PDT
Group : Development/Tools
Size : 791689
License : Librato, Inc.
Signature : RSA/SHA256, Fri 05 Aug 2011 08:47:22 AM PDT, Key ID 4bdb4cd3e9891ef5
Source RPM : librato-silverline-3.1.3-1.src.rpm
#!/usr/bin/env ruby
require 'cgi'
require 'uri'
require 'net/http'
require 'net/https'
USER = ARGV[0]
TOKEN = ARGV[1]
REGEX = ENV['REGEX'] ? Regexp.new(ENV['REGEX']) : /^(\S+)\s+(\S+)$/
#!/usr/bin/env ruby
Bundler.require :default
URL = ''
METRICS_USER = ''
METRICS_TOKEN = ''
def measure_request(url)
t0 = Time.now
@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/
class YourThing
def self.connection
@connection ||= Faraday::Connection.new do |b|
b.use Faraday::Request::UrlEncoded
# and all the rest
end
end
def connection
@connection ||= begin
@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 / hanging.rb
Created July 12, 2011 22:51
Hanging regex found by @jnunemaker
[1 : 0] eric@morizo:/Users/eric > irb
>> regex = /\A(?:%[0-9a-fA-F]{2}|[^%]+)*\z/
=> /\A(?:%[0-9a-fA-F]{2}|[^%]+)*\z/
>> str = "http%3A%2F%2Fwww.google.com%2Furl%3Fsa%3Dt%26source%3Dweb%26cd%3D1%26sqi%3D2%26ved%3D0CCkQFjAA%26url%3Dhttp%253A%252F%252Fnd.edu%252F%26rct%3Dj%"
=> "http%3A%2F%2Fwww.google.com%2Furl%3Fsa%3Dt%26source%3Dweb%26cd%3D1%26sqi%3D2%26ved%3D0CCkQFjAA%26url%3Dhttp%253A%252F%252Fnd.edu%252F%26rct%3Dj%"
>> regex =~ str
diff --git a/lib/rollout.rb b/lib/rollout.rb
index 4727b97..fe469f8 100644
--- a/lib/rollout.rb
+++ b/lib/rollout.rb
@@ -1,7 +1,10 @@
class Rollout
- def initialize(redis)
- @redis = redis
- @groups = {"all" => lambda { |user| true }}
+ attr_accessor :population
@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