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
@sandro
sandro / Rails load order.txt
Created July 22, 2009 17:43
Rails 2 loading order
Loading development environment (Rails 2.2.2)
config/environment.rb inside of Rails::Initializer.run block
config/environments/development.rb
vendor/plugins/
config/initializers
config/environment.rb inside of config.after_initialize block
gems in GEM_PATHS
lib/
Constants in lib/ are autoloaded when the constant is missing.
require 'benchmark'
n = 50000
# s = ""
# when 's' is global the benchmark runs much slower
Benchmark.bmbm do |x|
x.report("+=") do
s = ""
n.times { s += "." }
end
@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
require 'rubygems'
require 'rev'
class SomeWatcher < Rev::StatWatcher
def initialize(watch_path)
super(watch_path)
puts "watching #{path}"
end
def on_change
Error detected while processing CursorHold Auto commands for "*":
E303: Unable to open swap file for "[No Name]", recovery impossible
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'
# 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
@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
@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 / gist:293926
Created February 3, 2010 19:28
gem_console
alias gem_console='irb -I lib -r lib/*.rb'