Skip to content

Instantly share code, notes, and snippets.

View vitobotta's full-sized avatar

Vito Botta vitobotta

View GitHub Profile
require 'stringio'
require 'timeout'
class Object
def methods_returning(expected, *args, &blk)
old_stdout = $>
$> = StringIO.new
methods.select do |meth|
Timeout::timeout(1) { dup.public_send(meth, *args, &blk) == expected rescue false } rescue false

ruby-1.9.3-p484 cumulative performance patch for rbenv

(I guarantee nothing. No warranty I am not responsible blah blah blah. Seems to work great for me so far. Thanks to Tyler Bird who I forked this from.)

This installs a patched ruby 1.9.3-p484 with the railsexpress patchsets: https://github.com/skaes/rvm-patchsets

Requirements

class Scheduler < Rufus::Scheduler::PlainScheduler
def initialize(zk, *args)
super(*args)
@zk_locker = zk.exclusive_locker('scheduler')
end
def run
@zk_locker.with_lock do
configure

ruby-1.9.3-p448 cumulative performance patch for rbenv

(I guarantee nothing. No warranty I am not responsible blah blah blah. Seems to work great for me so far. Thanks to Tyler Bird who I forked this from.)

This installs a patched ruby 1.9.3-p448 with the railsexpress patchsets: https://github.com/skaes/rvm-patchsets

Requirements

ruby-1.9.3-p484 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p484 with the railsexpress patchsets: https://github.com/skaes/rvm-patchsets

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.

@vitobotta
vitobotta / contact_form.rhtml
Created April 22, 2011 21:19
ERB version of my Sinatra-powered contact form for Jekyll
See blog post at http://vitobotta.com/sinatra-contact-form-jekyll/
<!DOCTYPE html>
<html>
<head>
<link href='/stylesheets/contact-form.css' type='text/css' rel='stylesheet' media='screen' />
<meta name="robots" content="noindex, noarchive, noodp, noydir" />
</head>
<body>
<% if @sent == true %>
@vitobotta
vitobotta / brb-client-auto-reconnect.rb
Created May 13, 2011 14:27
Example of BrB Client with auto reconnec
class Client
attr_reader :hostname, :host, :port
def initialize(port, host)
@port, @host = port, host
connect!
EM.reactor_thread.join
end
def connect!
@vitobotta
vitobotta / connection-pool-test.rb
Created July 8, 2011 12:22
Connection pool testing with JRuby and MRI
require "rubygems"
if defined?(JRUBY_VERSION)
gem "activerecord-jdbc-adapter", '>= 1.0.2'
gem "activerecord-jdbcmysql-adapter", '>= 1.0.2'
gem 'jruby-openssl'
gem 'jdbc-mysql'
else
gem 'mysql2', '= 0.2.7'
end
@vitobotta
vitobotta / indexes.rake
Created September 13, 2011 16:42
List unindexed foreign keys
namespace :indexes do
desc "List unindexed foreign keys"
task :unindexed_foreign_keys => :environment do
ActiveRecord::Base.logger = Logger.new('/dev/null')
missing_indexes = {}
connection = ActiveRecord::Base.connection
connection.tables.collect do |table|