Skip to content

Instantly share code, notes, and snippets.

View leeadkins's full-sized avatar
🎯
Focusing

Lee Adkins leeadkins

🎯
Focusing
View GitHub Profile
@leeadkins
leeadkins / gist:3809218
Created October 1, 2012 02:52
Super simple hack to automatically switch to a specific Node version on CD (using NVM and ZSH)
# 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
@leeadkins
leeadkins / gist:764326
Created January 4, 2011 02:59
A lil somethin somethin
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
@leeadkins
leeadkins / user.rb
Created October 19, 2010 18:48 — forked from RSpace/user.rb
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
# 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