Skip to content

Instantly share code, notes, and snippets.

class Contact < ActiveRecord::Base
attr_accessible :email, :name, :track
validates :name, :email, :track, presence: true
validates :email, uniqueness: true
validates :track, inclusion: { in: %w(sales marketing software product) }
validates_format_of :email,:with => /^([^\s]+)((?:[-a-z0-9]\.)[a-z]{2,})$/i
before_validation :downcase_track
require 'spec_helper'
describe Contact do
it "should be invalid without a name" do
@contact = Contact.new(email: 'foo@foo.com', track: 'product')
@contact.should_not be_valid
end
it "should be invalid without an email" do
Ian Daniher http://itdaniher.com Nonolith Labs, LLC.
Mariah Dunn Microsoft
Reyner Crosby http://twitter.com/reyner Twitter
Andrew Carmedelle Lab126 (Amazon's Kindle subsidiary)
Gracie Sanford Lit Motors
Eric Schneider Harvest Automation
Kelsey Breseman http://www.instructables.com/member/SelkeyMoonbeam/ Instructables.com
Hannah Sarver litl
Tim Cameron Ryan https://github.com/timcameronryan Game Closure
Ariana Chae Alleyoop
@markchang
markchang / gist:2650952
Created May 10, 2012 03:59
persisting node.js opening mongo db
// MongoDB
var persistentDB = null;
function openDatabase(fn) {
if(persistentDB == null) {
db_connection.open(function(err,db) {
persistentDB = db;
fn(err,persistentDB);
})
} else {
fn(null, persistentDB);
// server
var io = require('socket.io').listen(app)
io.of('/chat').on('connection', function (sockets) {
// do some stuff
});
// client
var chat = io.connect('http://localhost/chat')
@markchang
markchang / gist:1951457
Created March 1, 2012 17:09
Importing ReadItLater HTML into Readability via email
#
# this requires the nokogiri and mail gems
# this requires a sendgrid account, since you don't want to deal
# with setting up smtp delivery on your own machine
# sendgrid gives you 200 emails/day free
#
# 1. export from readitlater
# 2. separate the Unread and Archive sections (this doesn't distinguish URLs)
# 3. configure SMTP and email destination
# 4. go
@markchang
markchang / gist:1935748
Created February 28, 2012 22:36
noejs on centos 6.2
yum groupinstall 'Development Tools'
yum install openssl-devel
git clone https://github.com/joyent/node.git
cd node
git checkout v0.6.11
./configure
make
make test
make install
@markchang
markchang / gist:1927451
Created February 27, 2012 22:09
Installing Node on Debian Squeeze
# super annoying, no locales installed by default
dpkg-reconfigure locales
# build essential for eventually building some native libs
aptitude install build-essential
# some basics
aptitude install tmux git curl ca-certificates openssl libssl-dev redis-server python-minimal
# build node
<html manifest='/cache/manifest'>
<head>
<link href='https://si0.twimg.com/twitter-mobile/76a2baaafd4af4df43c34a9ef8a2e566362cc9ab/images/apple-touch-icon-114.png' rel='apple-touch-icon-precomposed' />
<link href='https://si0.twimg.com/twitter-mobile/76a2baaafd4af4df43c34a9ef8a2e566362cc9ab/images/ic_favicon.png' rel='icon' type='image/png' />
<title>
Twitter
</title>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' id='viewport' name='viewport' />
<script type='text/javascript'>
//<![CDATA[
@markchang
markchang / gist:1479823
Created December 15, 2011 04:18
Share Intent
public void shareArticle() {
Map<String, String> values = new HashMap<String, String>();
values.put(TITLE, articleTitle);
values.put(URL, articleUrl);
this.localyticsSession.tagEvent(SHARE_EVENT, values);
StringBuilder shareTextBuilder = new StringBuilder();
shareTextBuilder.append("I'm currently reading \"");