Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Schlesinger ryansch

View GitHub Profile
@ryansch
ryansch / 0-readme.md
Created Dec 7, 2012 — forked from burke/0-readme.md
ruby-1.9.3-p327 cumulative performance patch for rbenv without gc patch
View 0-readme.md

ruby-1.9.3-p327 cumulative performance patch for rbenv without gc patch

This installs a patched ruby 1.9.3-p327 with various performance improvements without a backported COW-friendly GC to make things happy on heroku, 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.

@ryansch
ryansch / rbenv-install-system-wide.sh
Created Feb 20, 2012
rbenv install and system wide install on Ubuntu 10.04 LTS.
View rbenv-install-system-wide.sh
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Add rbenv to the path:
@ryansch
ryansch / move_to_rds.rb
Created Jan 24, 2012 — forked from guenter/move_to_rds.rb
A quick and dirty script to move a database into Amazon RDS (or any other database). Can transfer part of the data beforehand.
View move_to_rds.rb
require 'fileutils'
start_time = Time.now
SOURCE_DB = {
:name => 'db_name',
:user => 'db_user',
:password => 'db_pass',
:host => 'localhost'
View resque.pill
Bluepill.define_process_condition(:running_time) do
def initialize(options = {})
@below = options[:below]
end
def run(pid)
started = `ps -p #{pid} -o command`.match(/since (\d+)/)[1].to_i
Time.now - Time.at(started)
rescue
0
@ryansch
ryansch / redis-em.mdown
Created May 25, 2011 — forked from zacharyvoase/redis-em.mdown
Redis + EventMachine - CPS == WIN.
View redis-em.mdown

A (Nicer) Redis Client for EventMachine

Redis is my favourite key/value store; it’s flexible, easy to set up and insanely fast. [EventMachine][] is a popular Ruby library for doing asynchronous I/O using an event loop. Bindings already [exist][em-redis] for accessing a Redis server using EM’s async-I/O (courtesy of Jonathan Broad), but unfortunately the resulting code has to use [Continuation-Passing Style][cps] via Ruby blocks. A very basic example of what that looks like follows:

@ryansch
ryansch / s3up.py
Created May 17, 2011 — forked from mtigas/0001.markdown
Command-line s3 uploader that uses the MultiPart (chunked) S3 upload functionality to parallelize and speed up large file uploads.
View s3up.py
#!/usr/bin/env python
# coding=utf-8
#
# s3up.py
# 2010-2011, Mike Tigas
# https://mike.tig.as/
#
# Usage:
# s3up filename
# Uploads the given file to the DEFAULT_BUCKET (see below)
View chef.rb
# hack for the chef - we cannot read file in http_request resource
ruby_block "Set attributes for http request for #{database[:name]} #{database[:kind]}" do
block do
request = resources(:http_request => "Create backup record for #{database[:name]} #{database[:kind]}")
request.message({:backup => {:filename => compressed_file_name, :kind => database[:kind], :size => File.size(compressed_file_path)}})
end
end
http_request "Create backup record for #{database[:name]} #{database[:kind]}" do
url "http://some-url/backups"
View rvm-your-chef.rb
ruby_block "rvm use default" do
block do
Chef::Mixin::Command.popen4('bash -l -c "rvm use default && env"') do |p,i,o,e|
o.each_line do |line|
next if line.nil?
line.chomp!
next if line.empty?
env_bits = line.split("=")
ENV[env_bits[0]] = env_bits[1]
View Capfile
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
# Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks
after 'deploy:finalize_code', 'deploy:web:disable'
after 'deploy:start', 'deploy:web:enable'
namespace :deploy do
You can’t perform that action at this time.