This file contains 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
def flash_messages(options={}) | |
flash_names = [:success, :warning, :error, :information, :tip] | |
html = '' | |
flash_names.each do |flash_type| | |
html += flash_message_for( flash[flash_type], options ) if flash[flash_type] | |
end | |
raw html | |
end | |
def flash_message_for(message, options={}) |
This file contains 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
def try(method, *args, &block) | |
__send__(method.to_sym, *args, %block) if responds_to?(method.to_sym, true) | |
end |
This file contains 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
# Demonstration | |
class Contact < Tabless | |
column :name, :string | |
column :address, :string | |
end |
This file contains 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
# based on a Ryan Bates article http://railscasts.com/episodes/219-active-model | |
class Tableless | |
include ActiveModel::Validations | |
include ActiveModel::Conversion | |
extend ActiveModel::Naming | |
def self.attr_accessor(*vars) | |
@attributes ||= [] |
This file contains 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
Gem::Specification.new do |s| | |
s.name = 'worst_errors' | |
s.version = '0.1.0' | |
s.platform = Gem::Platform::RUBY | |
s.author = 'Luís Mendes' | |
s.email = 'lmmendes@gmail.com' | |
s.summary = 'Worst Errors!' | |
s.description = 'Worst Errors a more elequent name for better errors' | |
s.files = [] |
This file contains 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
require 'openssl' | |
def gen_key(name) | |
key = OpenSSL::PKey::RSA.new 1048 | |
file = File.new(name, "w") | |
file.write(key) | |
file.close | |
end | |
def get_key(name) |
This file contains 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
# encoding: utf-8 | |
# Validates that the specified attributes are fake e-mail from temp domains | |
# | |
# class Person < ActiveRecord::Base | |
# validates :email, :fake_email => true | |
# end | |
# | |
# class Person < ActiveRecord::Base | |
# validates :email, :fake_email => { :exclude => ['bobmail.info'] } |
This file contains 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
# encoding: utf-8 | |
class EmailValidator < ActiveModel::EachValidator | |
# Validates that the specified attribute is a valid e-mail address | |
# | |
# class Person < ActiveRecord::Base | |
# validates :email, :email => true | |
# end | |
# |
This file contains 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
upstream app { | |
# Path to Unicorn SOCK file, as defined previously | |
server unix:/servers/sites/backend-saas/shared/tmp/sockets/.unicorn.sock fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name passworks.io; | |
return 301 $scheme://www.passworks.io$request_uri; | |
} |
This file contains 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
#================================================================================================== | |
# Monkey Patch (lmmendes) | |
# MongoDB or in this case Mongoid and it's driver Moped have problems running some commands | |
# when the Primary node goes down and Moped tries to write to the database before | |
# refreshing the cluster info or at least trying the same command on each node before failing. | |
# From GitHub: | |
# Moped::Errors::ConnectionFailure: Could not connect to a primary node for replica set | |
# https://github.com/mongoid/moped/issues/348 | |
#================================================================================================== |
OlderNewer