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
class Array | |
DYNAMIC_MAPPER_REGEXP = /^map_([_a-zA-Z]\w*)_to_([_a-zA-Z]\w*)$/ | |
def method_missing(method, *args, &block) | |
dynamic_mapper?(method) do |match| | |
map_dynamically(match[1], match[2]) | |
end || super | |
end | |
def dynamic_mapper?(method) |
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 'bench_press' | |
extend BenchPress | |
reps 1000 | |
measure "=~" do | |
"abcdefg" =~ /a/ | |
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
alias gem_console='irb -I lib -r lib/*.rb' |
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
#!/usr/bin/env ruby | |
=begin | |
Author: Sandro Turriate | |
Permalink: http://gist.github.com/272583 | |
DESCRIPTION | |
----------- | |
Turn a Pivotal Tracker story id into the name of that story. |
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 the contributor's fork as a remote | |
# use '-f' to fetch their branches | |
git remote add -f contributor git://github.com/contributor/project.git | |
# checkout a new branch for the patch | |
git co -b fix_bug_branch contributor/fix_bug_branch | |
# rebase master into the branch | |
git rebase master |
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
# override the parsing for all formats, always return :sexy => true | |
class CustomParser < HTTParty::Parser | |
def parse | |
{:sexy => true} | |
end | |
end | |
# only change the way json is parsed | |
class CustomJsonParser < HTTParty::Parser | |
def json |
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
diff --git a/lib/rspactor/listener.rb b/lib/rspactor/listener.rb | |
index c2d70b2..0990045 100644 | |
--- a/lib/rspactor/listener.rb | |
+++ b/lib/rspactor/listener.rb | |
@@ -1,56 +1,33 @@ | |
-require 'osx/foundation' | |
-OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework' | |
+require 'rubygems' | |
+require 'fsevent' | |
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
Error detected while processing CursorHold Auto commands for "*": | |
E303: Unable to open swap file for "[No Name]", recovery impossible |
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 'rubygems' | |
require 'rev' | |
class SomeWatcher < Rev::StatWatcher | |
def initialize(watch_path) | |
super(watch_path) | |
puts "watching #{path}" | |
end | |
def on_change |
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
# ARCHFLAGS may or may not matter - I set mine up this way just in case. | |
~$ echo $ARCHFLAGS | |
-arch i386 -arch x86_64 | |
# Be sure to compile ruby with --enable-shared | |
~$ rvm install 1.9.1 --debug --reconfigure -C --enable-shared=yes | |
# Test to ensure that --enable-shared worked | |
~$ ruby -e "require 'rbconfig'; puts Config::CONFIG['ENABLE_SHARED']" | |
yes |