Skip to content

Instantly share code, notes, and snippets.

View hrp's full-sized avatar

Hiten Parmar hrp

View GitHub Profile
@hrp
hrp / case-insensitive-include.rb
Created December 28, 2013 01:29
Case insensitive String#include? benchmark
marking answers to http://stackoverflow.com/questions/9333952/in-ruby-how-to-make-the-string-include-method-ignore-case/9334066
# http://www.gutenberg.org/cache/epub/1661/pg1661.txt
strings = IO.read('sherlock.txt').scan(/\w+/) # 109,222 words
known = 500.times.map do
strings.sample.downcase.chars.map{ |c| rand<0.5 ? c.upcase : c }.join
end
words = known.flat_map{ |s| [s, s+"-"] } # \w does not include -
@hrp
hrp / gitconfig
Created December 28, 2013 01:01
gitconfig
[alias]
co = checkout
st = status
br = branch
ci = commit
cm = commit -m
cia = commit -a
lg = log -p
df = diff
dc = diff --cached
build_package_combined_patch() {
local package_name="$1"
{
curl https://raw.github.com/skaes/rvm-patchsets/master/patchsets/ruby/1.9.3/p448/railsexpress | xargs -I % curl https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p448/% | patch -p1
autoconf
./configure --prefix="$PREFIX_PATH" $CONFIGURE_OPTS
make -j 8
make install
} >&4 2>&1

ruby-1.9.3-p392 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p392 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.

@hrp
hrp / 0-readme.md
Created October 30, 2013 21:33 — forked from mattyoho/0-readme.md

Patched ruby 1.9.3-p125 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p125 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Huge thanks to funny-falcon for the performance patches.

! thinkprogress.org
thinkprogress.org###overlay-image
thinkprogress.org##.facebook-like-bottom
thinkprogress.org##.o-image
@hrp
hrp / spec.rb
Created May 28, 2013 22:15
WJ's homework.
require './string'
describe "String#condensify" do
it "encodes a string" do
input = "AAASSSDDDDRDDSASSDDDSSSAD"
output = "3A3S4DR2DSA2S3D3SAD"
input.condensify.should == output
end
it "encodes a string with no repeats" do
module MyModule
# Regenerating code
end unless __FILE__ == $0
if __FILE__ == $0
require 'savon'
split_on = "#" + " Regenerating code"
code = File.read(__FILE__).split(split_on).last
wsdl_file_path = File.join(File.dirname(__FILE__), ARGV.first || raise("Gimme file!"))
@hrp
hrp / setfirewall.sh
Created January 4, 2013 00:06
Get CentOS ready for Rails.
#!/bin/bash
#
# Flush all current rules from iptables
#
iptables -F
#
# Allow SSH connections on tcp port 22
# This is essential when working on remote servers via SSH to prevent locking yourself out of the system
#
<html>
<head>
</head>
<body>
<select style="width:300px" id="source">
<optgroup label="Alaskan/Hawaiian Time Zone">
<option value="AK">Alaska</option>
<option value="HI">Hawaii</option>
</optgroup>
<optgroup label="Pacific Time Zone">