Skip to content

Instantly share code, notes, and snippets.

View edison's full-sized avatar
🏠
Working from home

Edison Machado edison

🏠
Working from home
View GitHub Profile
@edison
edison / gist:2223851
Created March 28, 2012 05:17 — forked from bryckbost/gist:1040263
Capybara 1.0 and Chrome
# env.rb
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
Download chromedriver from http://code.google.com/p/selenium/downloads/list
mv chromedriver to /usr/local/bin so it's in your path.
@edison
edison / cruisecontrolrb
Created March 29, 2012 01:06
CruiseControl.rb init shell
#! /bin/sh
### BEGIN INIT INFO
# Provides: cruisecontrol.rb
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: CruiseControl.rb
# Description: Continuous build integration system. This runs the web interface.
### END INIT INFO
@edison
edison / cpf_validator.rb
Created May 3, 2012 15:53
CPF Validator
class CpfValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :invalid_cpf) unless valid_cpf?(value)
end
private
def valid_cpf?(cpf = nil)
return false if cpf.nil?
nulos = %w{12345678909 11111111111 22222222222 33333333333 44444444444 55555555555 66666666666 77777777777 88888888888 99999999999 00000000000}
@edison
edison / cnpj_validator.rb
Created May 3, 2012 15:52
CNPJ Validator
class CnpjValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :invalid_cnpj) unless valid_cnpj?(value)
end
private
def valid_cnpj?(cnpj=nil)
return false if cnpj.nil?
nulos = %w{11111111111111 22222222222222 33333333333333 44444444444444 55555555555555 66666666666666 77777777777777 88888888888888 99999999999999 00000000000000}
@edison
edison / sample
Created September 8, 2012 17:21
rails_girls
<div id="top">
<div id="logo">
</div>
<div id="section">
</div>
</div>
@edison
edison / css
Created September 8, 2012 17:41
rails girls
#outline {
width:800px;
margin:0 auto;
border:1px solid #ddd;
}
#logo {
display:inline-block;
}
@edison
edison / html
Created September 8, 2012 17:43
html
<!DOCTYPE html>
<html>
<head>
<title>Quotes</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
@edison
edison / home
Created September 8, 2012 17:49
home
<div class="hero-unit">
<blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
<small>Someone famous <cite title="Source Title">Source Title</cite></small>
</blockquote>
</div>
@edison
edison / form.rb
Created September 8, 2012 18:52
form
class QuotesController < ApplicationController
def home
respond_to :html
end
def new
@quote = Quote.new
respond_to :html
end
@edison
edison / form.html.erb
Created September 8, 2012 18:57
form
<div class="alert alert-error">
<% @quote.errors.full_messages.each do |msg| %>
<p><%= msg %></p>
<% end %>
</div>