This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// server | |
var net = require("net") | |
, server | |
; | |
server = net.createServer(function(socket){ | |
// socket.end("bye\n"); | |
socket.on("connect", function(){ | |
console.log("conectou\n"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/will_paginate.rb | |
module WillPaginate | |
module ActionView | |
def will_paginate(collection = nil, options = {}) | |
options[:renderer] ||= BootstrapLinkRenderer | |
super.try :html_safe | |
end | |
class BootstrapLinkRenderer < LinkRenderer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FileResource < ActiveRecord::Base | |
has_attached_file :attachment, | |
:storage => :s3, | |
:bucket => ENV['S3_BUCKET'], | |
:s3_credentials => { :access_key_id => ENV['S3_KEY'], | |
:secret_access_key => ENV['S3_SECRET'] }, | |
:path => 'files/:id/:filename', | |
:url => '/files/:id/:filename' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RIKUTATAMO, KIRIN KA TOKITOZUSKA. | |
# KI MIKATO CHISHIKATOARITAKACHIKU KATOFUCHIRIKITOJI FUMODO MEIKATOCHI. | |
# KADOCHIRIMOSHI: KUTEKIARIMOTO RINKAMIRIKATEMO. | |
class Tokitozuska | |
@@mirikashiari = { | |
"a" => "ka", | |
"b" => "zu", | |
"c" => "mi", | |
"d" => "te", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
edison$ rails s | |
=> Booting Mongrel | |
=> Rails 3.1.0.rc1 application starting in development on http://0.0.0.0:3000 | |
=> Call with -d to detach | |
=> Ctrl-C to shutdown server | |
Exiting | |
/Users/edison/.rvm/gems/ruby-1.9.2-p180/gems/haml-3.1.1/lib/haml/template/patch.rb:16:in `alias_method': undefined method `delegate_template_exists?' for class `ActionView::Base' (NameError) | |
from /Users/edison/.rvm/gems/ruby-1.9.2-p180/gems/haml-3.1.1/lib/haml/template/patch.rb:16:in `<class:Base>' | |
from /Users/edison/.rvm/gems/ruby-1.9.2-p180/gems/haml-3.1.1/lib/haml/template/patch.rb:12:in `<module:ActionView>' | |
from /Users/edison/.rvm/gems/ruby-1.9.2-p180/gems/haml-3.1.1/lib/haml/template/patch.rb:11:in `<top (required)>' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
edison$ rails s | |
=> Booting WEBrick | |
=> Rails 3.1.0.beta1 application starting in development on http://0.0.0.0:3000 | |
=> Call with -d to detach | |
=> Ctrl-C to shutdown server | |
[2011-05-19 22:07:41] INFO WEBrick 1.3.1 | |
[2011-05-19 22:07:41] INFO ruby 1.9.2 (2011-02-18) [x86_64-darwin10.7.0] | |
[2011-05-19 22:07:41] INFO WEBrick::HTTPServer#start: pid=4975 port=3000 | |
Error during failsafe response: "\xC3" from ASCII-8BIT to UTF-8 | |
/Users/edison/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.beta1/lib/active_support/buffered_logger.rb:104:in `write' |