Skip to content

Instantly share code, notes, and snippets.

View kbparagua's full-sized avatar

Karl Bryan Paragua kbparagua

View GitHub Profile

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
email !=~ /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
encrypted_password = BCrypt::Password.new password
if user.encrypted_password == encrypted_password
VALID_EMAIL_REGEX = /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
def valid_email? email
email =~ VALID_EMAIL_REGEX
end
def correct_password? user, password
encrypted_password = BCrypt::Password.new password
user.encrypted_password == encrypted_password
end
user.correct_password? password
VALID_EMAIL_REGEX = /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
def authenticate email, password
user = User.find_by_email email
if password.present? && valid_email?(email) && user.present? && correct_password?(user, password)
user
else
false
end
def authenticate email, password
user = User.find_by_email email
if password.nil? || email !=~ /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i || user.nil?
return false
end
encrypted_password = BCrypt::Password.new password
if user.encrypted_password == encrypted_password
user
# move up the singleton instance
Pacman.instance.move_up
# the same instance will move right
Pacman.instance.move_right
# the same instance will move down
Pacman.instance.move_down
class Pacman
def self.get_instance
# instantiate the singleton instance if it is not existing yet.
if @instance.nil?
@instance = Pacman.new
end
@instance
end