Skip to content

Instantly share code, notes, and snippets.

View elandesign's full-sized avatar

Paul Smith elandesign

View GitHub Profile
@elandesign
elandesign / 0-readme.md
Last active December 27, 2015 00:59 — forked from burke/0-readme.md

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.

#!/bin/bash
# XCode Tools
xcode-select --install
# Homebrew
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
# *nix tools
brew install git imagemagick memcached mongodb mysql nmap openssl qt rabbitmq rbenv ruby-build zookeeper bash-completion
@elandesign
elandesign / string-benchmark.rb
Created October 11, 2012 16:14
Different ways to build a 100MB string
require 'benchmark'
require 'stringio'
Benchmark.measure do
string = ''
100_000_000.times do
string << '0'
end
end
# => 17.530000 0.040000 17.570000 ( 17.794845)
@elandesign
elandesign / vcard_generator.rb
Created March 28, 2012 15:56
vcard_generator.rb
require 'rubygems'
require 'vpim'
require 'faker'
Faker::Config.locale = 'en-gb'
File.open('contacts.vcf', 'w') do |file|
1000.times do
fakename = [Faker::Name.last_name, Faker::Name.first_name]
card = Vpim::Vcard::Maker.make2 do |vcard|
@elandesign
elandesign / batch_resource.rb
Created November 8, 2011 09:15
Add find_each and find_in_batches functionality to ActiveResource
# Drop this into config/initializers
# The resource being consumed should honour the :page parameter (works great with will_paginate)
module ActiveResource
module Batches
module ClassMethods
def find_each(options = {})
find_in_batches(options) do |batch|
batch.each do |entry|
@elandesign
elandesign / can_squeel.rb
Created November 8, 2011 09:11
Monkey patches to make CanCan work with Squeel
# Drop this into config/initializers to get CanCan working with Squeel
if defined?(Squeel)
module Squeel
module Nodes
class Predicate
alias_method :method, :method_name
alias_method :column, :expr
end
end