Skip to content

Instantly share code, notes, and snippets.

View lucascaton's full-sized avatar

Lucas Caton lucascaton

View GitHub Profile
@lucascaton
lucascaton / capybara_select_dates_and_times.rb
Created April 21, 2011 16:13 — forked from szimek/capybara_select_dates_and_times.rb
Cucumber steps for selecting time and date (using Capybara)
require "xpath" # XPath is a separate gem now
module Cucumber
module Rails
module CapybaraSelectDatesAndTimes
def select_date(field, options = {})
date = Date.parse(options[:with])
selector = %Q{.//fieldset[contains(./legend, "#{field}")]}
within(:xpath, selector) do
find(:xpath, '//select[contains(@id, "_1i")]').find(:xpath, ::XPath::HTML.option(date.year.to_s)).select_option
pt-BR:
errors:
messages:
expired: 'expirou, por favor solicite um novo'
not_found: 'não encontrado'
already_confirmed: 'já foi confirmado, por favor tente fazer login'
not_locked: 'não estava bloqueado'
not_saved:
one: "1 erro impediu que %{resource} fosse salvo:"
other: "%{count} erros impediram que %{resource} fosse salvo:"
#
# Pra quem ficou com preguiça de ficar dando refresh na página da polícia
# federal na hora de solicitar o passaporte
#
require 'rubygems'
require 'net/http'
require 'uri'
cpf = "1234567890"
@lucascaton
lucascaton / cpf_cnpj_validators.rb
Created July 27, 2011 14:40 — forked from gouvermxt/cpf_cnpj_validators.rb
validação de CPF e CNPJ em Ruby
#------------------------------------------------------------------------------
# Rotinas para verificação de CPF e CNPJ
# Linguagem: Ruby
# Escrito por: André Camargo < andre@boaideia.inf.br > http://blog.boaideia.inf.br
# Use, copie, melhore a vontade! Patches são bem-vindos...
#------------------------------------------------------------------------------
def check_cpf(cpf=nil)
return false if cpf.nil?
nulos = %w{12345678909 11111111111 22222222222 33333333333 44444444444 55555555555 66666666666 77777777777 88888888888 99999999999 00000000000}
@lucascaton
lucascaton / LICENSE.txt
Created September 28, 2011 18:40 — forked from p01/LICENSE.txt
Sudoku Solver in 140bytes
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Mathieu 'p01' Henri <http://www.p01.org/releases/>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@lucascaton
lucascaton / gist:1289707
Created October 15, 2011 15:26 — forked from ferbass/gist:1289704
GitIgnore for xcode 4.x
!default.mode1v3
!default.mode2v3
!default.pbxuser
!default.perspectivev3
!default.xcworkspace
*.mode1v3
*.mode2v3
*.moved-aside
*.pbxuser
*.perspectivev3
# You can check if current symbol is equivalent the question string
#
# e.g.:
# :symbol.symbol? # => true
# :symbol1.symbol1? # => true
# :sym_bol.sym_bol? # => true
# :"sym-bol".sym_bol? # => true
# :"sym bol".sym_bol? # => true
class Symbol
def method_missing(meth, *args, &blk)
@lucascaton
lucascaton / 0-readme.md
Created March 11, 2012 23:41 — forked from burke/0-readme.md
ruby-1.9.3-p125 cumulative performance patch.

Patched ruby 1.9.3-p125 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p125 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Huge thanks to funny-falcon for the performance patches.

@lucascaton
lucascaton / application.rb
Created April 14, 2012 04:28 — forked from ugisozols/application.rb
assets lazily compiled in production
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
# Bundler.require *Rails.groups(:assets => %w(development test))
# If you want your assets lazily compiled in production, use this line
Bundler.require(:default, :assets, Rails.env)
end
@lucascaton
lucascaton / gist:2420977
Created April 19, 2012 13:27 — forked from fnando/gist:2420869
My JavaScript Guidelines