Skip to content

Instantly share code, notes, and snippets.

@eharsojo
eharsojo / git_everyday_use.sh
Last active January 4, 2016 01:29
Git common everyday use
git clone <repositry_url>
git pull
git branch -l
git checkout -f
git reset --hard HEAD
git add .
git rm <file_name>
git commit -m "messages"
@eharsojo
eharsojo / custom_validator.rb
Last active January 4, 2016 01:19
Simple rails validator class
# http://edgeguides.rubyonrails.org/active_record_validations.html#performing-custom-validations
# First Example - custom validator without options
===================================================
class CustomValidator < ActiveModel::Validator
def validate_each(record, attribute, value)
if validation_failed
record.errors[attribute] << "must have something todo with this value"
end
end