Skip to content

Instantly share code, notes, and snippets.

View tinogomes's full-sized avatar
😀

Celestino Gomes tinogomes

😀
View GitHub Profile
@tinogomes
tinogomes / gist:771796
Created January 9, 2011 16:34
Copy DVD with drutil
Insert the disc into your DVD drive.
Click Ignore
Open Terminal ( Applications -> Utilities -> Terminal
Type drutil status ( Get the Name i.e. /dev/disk1 )
Type dd if=/path_to_dvd of=/game_name.iso and wait 15 min
Type drutil eject to eject your game.
@tinogomes
tinogomes / duck_typing.rb
Created January 27, 2011 23:09
Duck Type example
# sobre duck typing
def say(talker)
puts talker.say
end
class Person
def say
"I'm a person"
end
end
# -*- coding: utf-8 -*-
class User < ActiveRecord::Base
INVALID_DOMAINS = %w(homail.com hotamil.com hotmial.com hormail.com hotmail.co hotmai.com gmal.com hotimail.com hotmil.com htmail.com hotmal.com hotamail.com hotmail.cm htomail.com gmail.com.br otmail.com)
validates_format_of :email, :with => /^([^@\s]+)@((?!#{INVALID_DOMAINS.join("|")})(?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_blank => true
end
diff --git Gemfile Gemfile
new file mode 100644
index 0000000..e654bff
--- /dev/null
+++ Gemfile
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in dbv.gemspec
+gemspec
sqlite: &sqlite
adapter: sqlite3
timeout: 5000
database: ./tmp/ap.development.db
mysql: &mysql
adapter: mysql
username: root
password:
host: localhost
@tinogomes
tinogomes / new_asserts_for_test_unit.rb
Created February 2, 2011 16:20
Turn protected and private methods to public assert_true assert_false
require 'test/unit'
module Test
module Unit
module TestCase
def turn_public_methods(klass)
klass.class_eval do
private_instance_methods.each { |instance_method| public instance_method }
private_methods.each { |method| public_class_method method }
end
@tinogomes
tinogomes / gist:1006296
Created June 3, 2011 13:03
.boolean? method for ruby objects
module RubyExt
module Boolean
module ClassMethods
def boolean?
["TrueClass", "FalseClass"].include?(self.name)
end
end
module InstanceMethods
def boolean?
@tinogomes
tinogomes / gist:1024912
Created June 14, 2011 13:40
Add custom field support for has_secure_password on ActiveModel
diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb
index 63380d6..49aa847 100644
--- a/activemodel/lib/active_model/secure_password.rb
+++ b/activemodel/lib/active_model/secure_password.rb
@@ -5,13 +5,14 @@ module ActiveModel
extend ActiveSupport::Concern
module ClassMethods
- # Adds methods to set and authenticate against a BCrypt password.
- # This mechanism requires you to have a password_digest attribute.
@tinogomes
tinogomes / gist:1032702
Created June 18, 2011 01:16
Isso foi feito por "profissionais" :/
<p class="continue_navegar">
<a href="#" title="Buffet Infantil">Buffet Infantil </a> <br><br>
<a href="#" title="Buffet em domicílio">Buffet em domicílio </a><br><br>
<a href="#" title="Aluguel de brinquedos">Aluguel de brinquedos </a><br><br>
<a href="#" title="Animação e recreação">Animação e recreação</a><br><br>
<a href="#" title="Artigos para festas">Artigos para festas</a><br><br>
<a href="#" title="Bolos e doces">Bolos e doces</a><br><br>
<a href="#" title="Cabeleireiro infantil">Cabeleireiro infantil</a><br><br>
<a href="#" title="Convites">Convites</a><br><br>
<a href="#" title="Decoração de festa">Decoração de festa </a><br><br>
@tinogomes
tinogomes / gist:1053737
Created June 29, 2011 12:32
.rdebugrc - ruby debug settings
# cat ~/.rdebugrc
set autoeval
set autoirb