This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
n = (ARGV.shift || 1000000).to_i | |
def append(words, n) | |
n.times { res = words.inject("") {|string, p| string << "#{p}_"} } | |
end | |
def join_under(words, n) | |
n.times { res = words.map{|s| s}.join("_") } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo su - | |
# mkdir /etc/resolver | |
# cat > /etc/resolver/test | |
nameserver 127.0.0.1 | |
port 2155 | |
^D | |
^D | |
$ brew install dnsmasq | |
$ dnsmasq --port=2155 --no-resolv --address=/.test/127.0.0.1 | |
$ ping foo.test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# A C Parser using the Parslet library. | |
# | |
# ANSI C Grammar: | |
# | |
# * http://www.lysator.liu.se/c/ANSI-C-grammar-l.html | |
# * http://www.lysator.liu.se/c/ANSI-C-grammar-y.html | |
# | |
require 'parslet' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def require_or_install(path, gem_name = path, version = '> 0') | |
require path | |
rescue LoadError | |
require 'rubygems' | |
require 'rubygems/user_interaction' | |
require 'rubygems/dependency_installer' | |
installer = Gem::DependencyInstaller.new | |
installer.install gem_name, version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add all gems in the global gemset to the $LOAD_PATH so they can be used in rails3 console with bundler | |
if defined?(::Bundler) | |
$LOAD_PATH.concat Dir.glob("#{ENV['rvm_path']}/gems/#{ENV['rvm_ruby_string']}@global/gems/*/lib") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ClassHook | |
extend_object Class | |
def new(sclass = Object, *args) | |
super(sclass.to_class, *args) | |
end | |
end | |
module ModuleHook | |
append_features Module |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define STRING char * | |
#define IF if( | |
#define THEN ){ | |
#define ELSE } else { | |
#define FI ;} | |
#define WHILE while ( | |
#define DO ){ | |
#define OD ;} | |
#define INT int | |
#define BEGIN { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ uname -a && git --version | |
Darwin asha.local 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386 | |
git version 1.7.2.1 | |
$ git clone git://github.com/github/gitignore.git | |
$ cd gitignore | |
$ # fetching over ssh | |
$ yes | head -5 | (while read ; do time git fetch [email protected]:github/gitignore.git; done) 2>&1 | grep real | |
real 0m2.103s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rvm install ruby-head-n18 --branch ruby_1_8 | |
rvm alias ruby-head-n18 1.8.8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> "1" =~ /(?<a>\d)/ && a | |
NameError: undefined local variable or method `a' for main:Object | |
from (irb):5 | |
from /Users/lee/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>' | |
>> /(?<a>\d)/ =~ "1" && a | |
=> "1" |