Skip to content

Instantly share code, notes, and snippets.

class UserValidator
include ActiveModel::Validations
def self.fields
[:username, :password, :email, :phone, :age]
end
attr_accessor(*fields)
validates :username,
Validator::Factory.register(self, UserValidator)
validates_with Validator
if UserValidator.new(user).valid?
user.save
redirect_to user_path(user)
else
render :new
end
class BaseValidator
include ActiveModel::Validations
def initialize(record_params = {})
self.class.fields.each do |field|
val = record_params[field]
send("#{field}=", val)
end
end
end
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
alias gff="git-flow feature"
alias be="bundle exec"
cd ~/projects
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/'
}
[alias]
st = status
ci = commit
co = checkout
di = diff
dc = diff --cached
amend = commit --amend
aa = add --all
ff = merge --ff-only
pullff = pull --ff-only
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello React!</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.1/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.1/react-dom.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
</head>
<body>
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello World');
});
app.listen(3000);
// calculator.js
System.register("calculator", [], function (_export) {
"use strict";
var __moduleName = "calculator";
function sum(a, b) {
return a + b;
}
return {
let app = Express();