Skip to content

Instantly share code, notes, and snippets.

Jeremy Seitz somebox

Block or report user

Report or block somebox

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
somebox / unicorn-graphite.rb
Created Nov 12, 2013
Graphing unicorn active/queued processes (via sockets)
View unicorn-graphite.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'raindrops'
require 'statsd'
# This script monitors the active and queued unicorn processes.
# It uses the raindrops gem to look at the unix domain socket.
# Stats are polled every second (for one minute) and pushed to
# statsd as a counter. This script runs once a minute.
somebox /
Last active Jul 18, 2016
graphite-redis : monitor redis statistics with graphite across several hosts
#!/usr/bin/env ruby
require 'socket'
# This script runs every minute, captures stats about redis
# and forwards them to graphite as counter values.
# Graphite/carbon settings
View gist:6553626
>> h={a:true,b:false,c:1}
=> {:a=>true, :b=>false, :c=>1}
>> h[:a].present?
=> true
>> h[:a].presence
=> true
>> h[:b].present?
=> false
>> h[:b].presence
=> nil
somebox / i18ndocs.diff
Created May 9, 2012
i18ndocs changes
View i18ndocs.diff
diff --git a/Gemfile b/Gemfile
index 34fced8..7edff29 100644
--- a/Gemfile
+++ b/Gemfile
@@ -16,6 +16,8 @@ group :development do
gem "bundler", ">= 1.0.0"
gem "jeweler", ">= 1.8.3"
gem "simplecov",">= 0.5"
+ gem "fastercsv"
+ gem "i18n"
somebox / application_controller.rb
Created May 3, 2012
rescue from routing errors
View application_controller.rb
rescue_from ActionController::RoutingError do |exception|
render :file => Rails.root.join('public', '404.html'), :status => "404", :layout=>false
somebox / nginx.conf
Created Mar 13, 2012
Nginx error page handling
View nginx.conf
# The following recipe works with upstream rails proxy for custom 404s and 500s.
# Errors are usually handled via rails except if proxy is really down, in which case
# nginx needs a bit more configration.
server {
# ...
location / {
error_page 404 = @rails; # let rails show a page with suggestions
try_files maintenance.html @rails;
somebox / unicorn.rb
Created Mar 7, 2012
unicorn.rb file to deal with dead processes/stale pid and knows about RVM
View unicorn.rb
APP_ROOT = File.expand_path(File.dirname(File.dirname(__FILE__)))
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! APP_ROOT
rescue LoadError
# A More Awesome PS1
# - only show username if its not the usual one
# - only show hostname if its not my local box (checks SSH_CONNECTION)
# - show root username in red
# - show current path, and smart truncate longer ones (>35 chars)
# - show git branch in brackets
# - show a red star for uncommitted git changes
# - show local hostname in green (192.*,10.*,::1)
# - show other hostnames in white
somebox /
Created Sep 26, 2011 — forked from metaskills/gist:756111
Rails 3 Models To Export Mephisto To Octopress & Disqus
require 'builder'
require 'digest/md5'
class Content < ActiveRecord::Base
belongs_to :user
class Section < ActiveRecord::Base
has_many :assigned_sections
has_many :articles, :order => 'position', :through => :assigned_sections
somebox / README
Created Sep 20, 2011 — forked from indirect/README
Update WebKit nightly
To use this:
1. check out the gist somewhere
2. edit the plist to contain the path to the .rb file
3. run this:
chmod +x update-webkit.rb
launchctl load com.indirect.update-webkit.plist
You can’t perform that action at this time.