Skip to content

Instantly share code, notes, and snippets.

View rafaelss's full-sized avatar

Rafael Souza rafaelss

View GitHub Profile
@rafaelss
rafaelss / no patch
Created February 14, 2012 00:43
ruby 1.9.3 cumulative path - https://gist.github.com/1688857
$ time ruby script/test_recurrence.rb
bundle exec ruby script/test_recurrence.rb
real 0m9.903s
user 0m7.250s
sys 0m1.205s
real 0m8.395s
user 0m7.157s
sys 0m1.101s
@rafaelss
rafaelss / output.txt
Created February 3, 2012 13:12
should_receive/should_not_receive and respond_to?
require "rspec/mocks"
include RSpec::Mocks::Methods
class MyClass; end
MyClass.should_receive(:my_method).never
puts MyClass.respond_to?(:my_method)
class MyOtherClass; end
@rafaelss
rafaelss / rails_3_0_10
Created September 5, 2011 00:24
where is monday?
ruby-1.9.2-p290 :001 > Date.today
=> Sun, 04 Sep 2011
ruby-1.9.2-p290 :002 > Date.tomorrow
=> Mon, 05 Sep 2011
@rafaelss
rafaelss / README.md
Created September 5, 2011 00:05
Countdown Quiz

Countdown - Numbers Round

To run the code you must follow the commands below:

gem install riot # or sudo gem intall riot
git clone git://gist.github.com/1193748.git
cd 1193748
ruby -I. countdown_test.rb

I choose use riot as test framework. I'm using it in some small projects

function _bundle_exec() {
if [ -e Gemfile ]; then
grep -q "$1" "Gemfile.lock"
if [[ "$1" == "ruby" || $? -eq 0 ]]; then
echo "bundle exec $@"
bundle exec $@
return
fi
fi
require "rubygems"
require "typhoeus"
require "awesome_print"
def run(follow)
request = Typhoeus::Request.new("http://www.google.com", :method => :get)
request.follow_location = follow
hydra = Typhoeus::Hydra.new
hydra.queue(request)
@rafaelss
rafaelss / gist:1006315
Created June 3, 2011 13:13 — forked from tinogomes/gist:1006296
.boolean? method for ruby objects
module RubyExt
module Boolean
def bool?
[ true, false ].include?(self)
end
end
end
::Object.__send__ :include, RubyExt::Boolean
OpenSSL::SSL::SSLError:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
before_filter :load_comments, :only => [ :index, :create ]
def index
end
def create
@comment = Comment.new(params[:comment])
if @comment.save
render 'index'
end
def index
@trainers = if params[:franchise_id]
Trainer.where(:franchise_id => params[:franchise_id]).all
else
Trainer.all
end
end