Skip to content

Instantly share code, notes, and snippets.

View rafaelss's full-sized avatar

Rafael Souza rafaelss

View GitHub Profile
$ thin -R config.ru -D start
/Users/rafael/.rvm/gems/ruby-1.9.2-preview1/gems/activesupport-2.3.5/lib/active_support/core_ext/try.rb:29: [BUG] rb_add_method: unsupported method type (8)
ruby 1.9.2dev (2009-07-18 trunk 24186) [i386-darwin9.8.0]
-- control frame ----------
c:0043 p:---- s:0127 b:0127 l:000126 d:000126 CFUNC :alias_method
c:0042 p:0044 s:0122 b:0122 l:000121 d:000121 CLASS /Users/rafael/.rvm/gems/ruby-1.9.2-preview1/gems/activesupport-2.3.5/lib/active_support/core_ext/try.rb:29
c:0041 p:0009 s:0120 b:0120 l:000119 d:000119 TOP /Users/rafael/.rvm/gems/ruby-1.9.2-preview1/gems/activesupport-2.3.5/lib/active_support/core_ext/try.rb:1
c:0040 p:---- s:0118 b:0118 l:000117 d:000117 FINISH
# spec/support/matchers/attribute.rb
module AttributeMatchers
Spec::Matchers.define :have_only_attributes do |attributes|
match do |target|
actual_attributes = target.attribute_names.map(&:to_sym)
diff = ((actual_attributes | attributes) - (actual_attributes & attributes))
diff.length == 0
end
end
# using implicit subject may throw the following error on ruby 1.9.2
# wrong number of arguments (1 for 0)
# /Users/rafael/.rvm/gems/ruby-1.9.2-head/gems/rspec-1.3.0/lib/spec/example/subject.rb:43:in `block in implicit_subject'
# /Users/rafael/.rvm/gems/ruby-1.9.2-head/gems/rspec-1.3.0/lib/spec/example/subject.rb:77:in `instance_eval'
# /Users/rafael/.rvm/gems/ruby-1.9.2-head/gems/rspec-1.3.0/lib/spec/example/subject.rb:77:in `subject'
# /Users/rafael/.rvm/gems/ruby-1.9.2-head/gems/rspec-1.3.0/lib/spec/example/subject.rb:25:in `block (2 levels) in its'
# /Users/rafael/.rvm/gems/ruby-1.9.2-head/gems/rspec-1.3.0/lib/spec/example/subject.rb:91:in `should'
# spec/models/category_spec.rb:17:in `block (3 levels) in <top (required)>'
@rafaelss
rafaelss / Gemfile
Created May 20, 2010 22:18 — forked from rmanalan/.gems
rack static site
source "http://rubygems.org"
gem 'rack-contrib', :git => 'git://github.com/rack/rack-contrib.git'
gem 'rack-rewrite'
def test_array_of_arrays
template = <<template
{{#items}}
start
{{#map}}
{{a}}
{{/map}}
end
{{/items}}
template
class Expression
include Mongoid::Document
field :english
end
# idéia original em php: http://goncin.wordpress.com/2010/06/21/ditados-populares-em-php/
###############
if tempo.is?(:chuvoso)
cavalinho.recolher
end
################
#!/usr/bin/env ruby
current = `defaults read com.apple.finder AppleShowAllFiles`
current = current.strip == 'TRUE' ? 'FALSE' : 'TRUE'
`defaults write com.apple.finder AppleShowAllFiles #{current}`
`killall Finder`
#!/usr/bin/env python
# Try to determine how much RAM is currently being used per program.
# Note the per program, not per process. So for example this script
# will report mem used by all httpd process together. In detail it reports:
# sum(all RSS for process instances) + max(shared mem for any process instance)
#
# The shared calculation below will factor out shared text and
# libs etc. within a program, but not between programs. So there
function _git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function _rvm_gemset {
rvm gemset name | sed -e '/^$/d' -e 's/\(.*\)/ \1/'
}
function reload {
source ~/.bash_profile