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
@defunkt
defunkt / connection_fix.rb
Created November 19, 2009 20:00
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/
module RackHeaderHack
def set_headers(headers)
driver = page.driver
def driver.env
@env.merge(super)
end
def driver.env=(env)
@env = env
end
driver.env = headers
~/repo/ruby
$ mkdir rails/hacker-uplink && cd rails/hacker-uplink && touch Gemfile

~/repo/ruby/rails/hacker-uplink
$ ls
Gemfile

~/repo/ruby/rails/hacker-uplink
$ git init

Initialized empty Git repository in /Users/krainboltgreene/repo/ruby/rails/hacker-uplink/.git/

@markoa
markoa / deploy.rb
Created October 10, 2011 13:31
Ingredients to monitor Resque with God automatically via Capistrano (on Ubuntu)
namespace :deploy do
desc "Hot-reload God configuration for the Resque worker"
task :reload_god_config do
sudo "god stop resque"
sudo "god load #{File.join(deploy_to, 'current', 'config', 'resque-' + rails_env + '.god')}"
sudo "god start resque"
end
end
# append to the bottom:
@eregon
eregon / README.md
Created October 11, 2011 18:08
Theorical benchmark of `require` time when using Yura Sokolov's patch [Feature #5427]

This is a theoretical benchmark of require time comparing ruby 1.9.4 r33453 original and patched on a 64-bit Linux with a sequential hard disk.

It is theoretical because it is based on requiring a few hundreds empty files from the same folder, which is likely rare.

However, the global result (patched significantly faster than original) should be reflected in a certain measure in real life.

It is showing especially good results, because a file is never required twice, and so the unpatched version always has to check every file loaded.

The patched version could actually be slower when:

diff --git a/load.c b/load.c
index 9ed386d..1a6f5e9 100644
--- a/load.c
+++ b/load.c
@@ -270,7 +270,7 @@ rb_provide(const char *feature)
NORETURN(static void load_failed(VALUE));
static void
-rb_load_internal(VALUE fname, int wrap)
+rb_load_internal(VALUE fname, VALUE wrap)
require 'date'
class Date
# Try to read Marshal data of 1.9.3 Date
# !!CAUTION: COMPLETELY UNTESTED!!!
if RUBY_VERSION < "1.9.3"
def marshal_load(ary)
case ary.size
when 3
@ajd, @of, @sg, = ary
@sattybhens
sattybhens / excel_formulas.rb
Created December 28, 2011 05:35
discover unique excel formula's using JRuby and POI
# Given an Excel file... iterate over each cell that has a formula
# and collect all the unique formula signatures
# formula signature are in RPN and shown as
# => Ref#UnaryMinus#Ref#Multiply#Int#Int#Power#Divide#Ref#Multiply
# => Ref#Ref#Multiply#Ref#Ref#Multiply#Subtract#Parenthesis#Ref#Multiply#Int#Int#Power#Divide#Ref#Subtract
# => Ref#Ref#Multiply#Ref#Ref#Multiply#Subtract#Parenthesis#Ref#Multiply#Int#Int#Power#Divide#Ref#Multiply#Ref#Subtract
# => Ref#Ref#Multiply#Int#Int#Power#Divide
# => Ref#Area#Attr#Ref#Multiply#Ref#Multiply#Parenthesis#Divide
# => Ref#Area#Attr#Ref#Multiply#Int#Int#Power#Divide#Ref#Multiply#Parenthesis#Divide
# => Ref#Area#Attr#Ref#Multiply#Int#Int#Power#Divide#Parenthesis#Divide
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.