Skip to content

Instantly share code, notes, and snippets.

# Package Maintainer: Increment phusion_release to match latest release available
%define phusion_release 2011.03
Summary: Ruby Enterprise Edition (Release %{phusion_release})
Name: ruby-enterprise
Vendor: Phusion.nl <info@phusion.nl>
Packager: Adam Vollrath <hosting@endpoint.com>
Version: 1.8.7
Release: 8%{dist}
License: Ruby or GPL v2
@tmm1
tmm1 / debug.rb
Created October 14, 2009 06:48
debug a process using strace/gdb
# collect information about a running process
# ruby debug.rb <pid>
begin
raise ArgumentError unless pid = ARGV[0]
pid = pid.to_i
raise ArgumentError unless pid > 0
Process.kill(0,pid)
rescue TypeError, ArgumentError
raise 'pid required'
@tmm1
tmm1 / iterator.rb
Created October 30, 2009 08:28
simple eventmachine async iterator
module EventMachine
# A simple iterator for concurrent asynchronous work.
#
# Unlike ruby's built-in iterators, the end of the current iteration cycle is signaled manually,
# instead of happening automatically after the yielded block finishes executing. For example:
#
# (0..10).each{ |num| }
#
# becomes:
#
@eric
eric / require_tracking.rb
Created December 28, 2009 02:18
A simple tool to gather memory usage when files are required. More info at: http://bitmonkey.net/post/308322913
#
# Created by Eric Lindvall <eric@sevenscale.com>
#
# WHAT: Provides a simple overview of memory allocation occuring during a
# require.
#
# For a longer explanation, see my post at:
#
# http://bitmonkey.net/post/308322913/tracking-initial-memory-usage-by-file-in-ruby
#
@defunkt
defunkt / checkout.md
Created March 3, 2010 21:34
Tracking branch shortcut

Old way:

$ git checkout -b preandpost_fork_hooks  scotttam/preandpost_fork_hooks
Branch preandpost_fork_hooks set up to track remote branch preandpost_fork_hooks from scotttam.
Switched to a new branch 'preandpost_fork_hooks'

New way:

$ git checkout preandpost_fork_hooks

Branch preandpost_fork_hooks set up to track remote branch preandpost_fork_hooks from scotttam.

# silly but useful.
# -> compresses nested hashes into dot separated key value pairs
class Hash
def nested_flatten(prefix = 'h')
arr = []
each do |key, value|
k = prefix + ".#{key}"
# sample tcp balancer to balance between two TCP brokers
global
log 127.0.0.1 local0 info
defaults
clitimeout 60000 # maximum inactivity time on the client side
srvtimeout 30000 # maximum inactivity time on the server side
timeout connect 8000 # maximum time to wait for a connection attempt to a server to succeed
defaults
mode http
clitimeout 600000 # maximum inactivity time on the client side
srvtimeout 600000 # maximum inactivity time on the server side
timeout connect 8000 # maximum time to wait for a connection attempt to a server to succeed
balance roundrobin # each server is used in turns, according to assigned weight
frontend http
module God
module Conditions
class FileTouched < PollCondition
attr_accessor :path
def initialize
super
self.path = nil
end
@jnewland
jnewland / .caprc
Created August 21, 2010 17:44
toss this in your ~/.caprc, then `cap cowboy staging deploy`. Use carefully.
namespace :cowboy do
desc 'Deploy without SCM'
task :default do
deploy_stage = fetch(:stage, 'none')
set :repository, "."
set :deploy_via, :copy
set :scm, :none
set :stage, deploy_stage
set :cowboy_deploy, true
set :copy_exclude, [".git/*", ".svn/*", "log/*", "vendor/bundle/*"]