Skip to content

Instantly share code, notes, and snippets.

View rinaldifonseca's full-sized avatar

Rinaldi Fonseca rinaldifonseca

View GitHub Profile
def transfere(to, valor)
to.link("transfer").post(:valor => valor)
end
def processa_pagamento(pessoa, aulas, consultorias, opensource, bank)
parcelas = []
total = 0
aulas.each do |a|
aula.verify do |v|
@rinaldifonseca
rinaldifonseca / dijkstras_dci.rb
Created September 2, 2012 18:53 — forked from MitinPavel/dijkstras_dci.rb
Dijkstra's algorithm in DCI -- Example in Ruby
#!/usr/bin/env ruby
#
######################################################################################################################################
# Taken here http://fulloo.info/Examples/RubyExamples/Dijkstra/DijkstraListing.html and carefully corrected to be more ruby idiomatic.
######################################################################################################################################
#
# Example in Ruby -- Dijkstra's algorithm in DCI
# Modified and simplified for a Manhattan geometry with 8 roles
#
#
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'
Home Page
Failure/Error: visit product_path product
Capybara::Poltergeist::JavascriptError:
One or more errors were raised in the Javascript code on the page:
SyntaxError: Parse error
TypeError: 'null' is not an object (evaluating 'images[$($("#product-variants input[type=radio]")[0]).val()]')
@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