Skip to content

Instantly share code, notes, and snippets.

View rinaldifonseca's full-sized avatar

Rinaldi Fonseca rinaldifonseca

View GitHub Profile
require 'benchmark/ips'
h = { foo: :bar }
Benchmark.ips do |r|
r.report('#[]') { h[:foo] }
r.report('#fetch') { h.fetch(:foo) }
end

[ruby-dev:39421] exception from open-uri

Yusuke ENDOH writes:

Periodically when fetching web pages using open-uri, he notices that many different kinds of exceptions can be raised.

So far, he’s experienced these below:

  • Errno::ETIMEDOUT

@rinaldifonseca
rinaldifonseca / application_controller.rb
Created August 13, 2012 17:07 — forked from joewest/application_controller.rb
Cross-origin resource sharing in rails
class ApplicationController < ActionController::Base
protect_from_forgery
after_filter :set_access_control_headers
def set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Request-Method'] = '*'
end
end
[cmilfont@milfont:/Users/cmilfont/projetos/forteschat3/oraculo:homologacao:a1a293f:+M]
$ rspec spec/integration/chamado_spec.rb -e "Deveria submeter a dúvida para a tela de Faqs"
Run filtered including {:full_description=>/(?-mix:Deveria\ submeter\ a\ dúvida\ para\ a\ tela\ de\ Faqs)/}
Chamado
Como cliente
Pagina inicial
DEPRECATION WARNING: <% %> style block helpers are deprecated. Please use <%= %>. (called from _app_views_chamados_index_html_erb__1905729048714370975_2183758900_2238918427965469768 at /Users/cmilfont/projetos/forteschat3/oraculo/app/views/chamados/index.html.erb:40)
http://127.0.0.1:51920/javascripts/vendor/jquery-1.7.1.min.js:4 TypeError: Result of expression 'o' [null] is not an object.
Deveria submeter a dúvida para a tela de Faqs (FAILED - 1)
@rinaldifonseca
rinaldifonseca / Gemfile
Created July 25, 2012 02:07 — forked from lgs/Gemfile
Goliath.io with Grape and MongoDB
gem 'mongo'
gem 'em-mongo'
gem 'bson_ext'
gem 'goliath'
gem 'grape'
@rinaldifonseca
rinaldifonseca / Gemfile
Created July 24, 2012 04:50 — forked from smd686s/Gemfile
Goliath.io with Grape and MongoDB
gem 'mongo'
gem 'em-mongo'
gem 'bson_ext'
gem 'goliath'
gem 'grape'
@rinaldifonseca
rinaldifonseca / card_creator.rb
Created July 20, 2012 19:51 — forked from tooky/card_creator.rb
Moving response callbacks out of controller
class CardCreator < Struct.new(:listener)
def create(iteration, attributes)
card = iteration.cards.build(attributes)
if card.save
listener.created(card)
else
listener.create_failed(card)
end
end
end
@rinaldifonseca
rinaldifonseca / config.rb
Created July 15, 2012 20:42
EM-Mongo with Goliath
config['mongo'] = EventMachine::Synchrony::ConnectionPool.new(size: 20) do
conn = EM::Mongo::Connection.new('localhost', 27017, 1, {:reconnect_in => 1})
conn.db('muisco')
end
@rinaldifonseca
rinaldifonseca / gist:3101121
Created July 12, 2012 21:27 — forked from viniciusteles/gist:556029
Sete Atitudes para Hackear a Indústria de Software
Sete Atitudes para Hackear a Indústria de Software
By Klaus Wuestefeld
1) Torne-se excelente.
Seja realmente bom em alguma coisa. Não fique só choramingando ou
querendo progredir às custas dos outros. Não pense q pq vc sentou 4
anos numa faculdade ouvindo um professor falar sobre software q vc
sabe alguma coisa. Jogador de futebol não aprende a jogar bola tendo
@rinaldifonseca
rinaldifonseca / Plea.markdown
Created July 11, 2012 03:41 — forked from justinko/Plea.markdown
Am I doing it wrong?

Dear Rubyists,

I just lost a contract because of my code in a Rails project.

The specific code in question is related to a "posting a comment" feature. Here are the details:

In this project, "posting a comment" does not simply entail inserting a row into the database. It involves a procedure to yes, insert a row, but also detect its language, check for spam, send emails, and "share" it to Twitter and Facebook. I believe this algorithm should be encapsulated. I do not believe it belongs in a controller or a model. I do not believe Active Record callbacks should be used.

The "senior developer", whom is the stake holder's right hand man, said this: