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
# Detects if a .nvmrc file exists, and switches | |
# to the specified version if it does. | |
# The contents of the .nvmrc file should simply be the node | |
# version to use, like "v0.8.11" | |
# Put this in your .zshrc file or somewhere else that is loaded automatically | |
function chpwd() { | |
emulate -L zsh | |
if [[ -f .nvmrc ]] then | |
nvm use `cat .nvmrc` | |
fi |
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
class Fun | |
def errors | |
@errors ||= [] | |
end | |
def valid? | |
@errors.clear | |
self.class.validations.each do |method, validation| | |
if instance_eval(&validation[:prc]) == false | |
@errors << {:validator => method, :message => validation[:message]} | |
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
class User < ActiveRecord::Base | |
devise :database_authenticatable, :openid_authenticatable, :recoverable, :rememberable, :trackable, :validatable | |
# Handle creation of user authenticated via OpenID | |
def self.create_from_identity_url(identity_url) | |
User.new(:identity_url => identity_url) | |
end | |
# Set email as a required field from the Open ID provider |
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
# NearlyHumanize | |
# The default Rails Humanize methods always capitalizes strings before returning them, | |
# even if you explicitly set an inflect.human with some unique capitalization in your initalizers. | |
# Sometimes you want that, but for the times you don't, here's a new method - nearly_humanize | |
# You can use this in any place you'd normally use humanize, but if it finds a custom inflection | |
# that you've provided in your initializers, it won't capitalize it. Otherwise, it works like the | |
# original humanize. | |
# To use, paste this into an initializer or some other file you have loading at boot |