Skip to content

Instantly share code, notes, and snippets.

View sandro's full-sized avatar
☀️
Sharing Goodness

Sandro Turriate sandro

☀️
Sharing Goodness
View GitHub Profile
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)
@sandro
sandro / report.markdown
Created March 17, 2010 19:43 — forked from jamesgolick/gist:334347
benchmark regexp matching
require 'bench_press'
extend BenchPress
reps 1000
measure "=~" do
"abcdefg" =~ /a/
end
@sandro
sandro / gist:293926
Created February 3, 2010 19:28
gem_console
alias gem_console='irb -I lib -r lib/*.rb'
@sandro
sandro / tracker_story_name.rb
Created January 8, 2010 23:44
fetch pivotal tracker story name from id
#!/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.
@sandro
sandro / merge a fork.txt
Created November 20, 2009 06:20
merge a pull request
# 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
# 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
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'
Error detected while processing CursorHold Auto commands for "*":
E303: Unable to open swap file for "[No Name]", recovery impossible
require 'rubygems'
require 'rev'
class SomeWatcher < Rev::StatWatcher
def initialize(watch_path)
super(watch_path)
puts "watching #{path}"
end
def on_change
@sandro
sandro / gist:204016
Created October 7, 2009 13:12
Compile Ruby Cocoa on Snow Leopard
# 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