Skip to content

Instantly share code, notes, and snippets.

## Routes
map.add_person '/add_person', :controller => 'people', :action => 'new_unclaimed_person'
map.add '/add', :controller => 'people', :action => 'create_unclaimed_person'
## People Controller
def new_unclaimed_person
@person = Person.new
@chrisconley
chrisconley / notes.sh
Last active August 29, 2015 14:05
Docker Fig with boot2docker and rsync
# This assumes Docker, Fig, and boot2docker have already been installed
# and that you've set up the app specified in Fig's Quick Start at http://www.fig.sh/.
# Try it!
boot2docker init
boot2docker up
export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375
fig up
# Uh oh, that didn't work, let's set up rsync
ssh-dss AAAAB3NzaC1kc3MAAACBAKBq9E2i52pC4cjt6iif/kWaNtgO8cAqEHBkIjGQMFJMImn+MLVqFBjn7BgjJRHFFxhsg5MsdBIgDd0vURNV+SkvF5PadivjFshcFldbouL9RHhxNnVz2UjUAX4iPGfezEW+VW72KnewQIBrAA+RKZ/Mz6+7aSYms87R0Gyb+vmJAAAAFQCFMiwCWLQELd6O3q1FjOKRZ+7dkwAAAIAKs89OByO2XFqjSK9zF0zxu2KJn0P6Dm804b44Yt7UYt9YGuqyEGg7asT7GBWth9L8UnCmTk5gawcH3bS41VQSkyPXDRXDwB23mBzi/UQnmNnAJGH16KaKGNj3uB1U8T/n4SO7grl0Fyz4gBEL98zvBjRXpbPvEBLpkaFBxJLx7wAAAIA2rEjdApmzssKTYgJw6IlGmvT/sQvVdLhazvst0Rj48JoDQJadIKMMoJjbepWYKX6Vw4SIJf9HZyWzZHozY2E0BrHQvko8dOoPoJFmoAUK/KDKIIfp/S1N1V6/yZV+v5PsiaFQlCJNHhNRhm4tQqEFdEu0nXklY99NYmv/W5yjtg== chris@chris-mbp.local
- (void)dealloc {
[name release];
[description release];
[super dealloc];
}
class Domain < ActiveRecord::Base
named_scope :length, lambda {|length| {:conditions => ["length = ?", length]} if !length.blank? || length == 'all'}
named_scope :viewable, lambda {{:conditions => ["viewable_at < ?", Time.now.utc]}}
named_scope :public, lambda {|public| {:conditions => ["public = ?", true]} if !public.blank?}
end
def self.search(options = {})
self.length(options[:length]).viewable.public(options[:public])
end
Spec::Matchers.define :require do |attribute|
match do |object|
factory = object.class.name.downcase.to_sym
object = Factory.build(factory, attribute => "")
!object.valid?
end
end
describe User do
it "should be valid given valid attributes" do
# Finds all setter methods for the object,
# builds a new object with these methods set to an arbitrary value,
# checks if the given attrs are able to be mass assigned and all others are not,
# and finally returns true if there are no failures.
Spec::Matchers.define :only_mass_assign_accessible_attributes do |*attrs|
match do |object|
setters = object.methods.map{|m| m if m.match(/[a-z].*\=$/)}.compact
getters = setters.map{|s| s.gsub('=', '').to_sym}
params = {}
class ScheduleTime
attr_reader :seconds, :orig_hour, :hour, :minute, :second
def initialize(time, time_of_day)
#raise ArgumentError
@time = time
@time_of_day = time_of_day
parse_time
end
def parse_time
class HuzzahsController < ApplicationController
before_filter :login_required
before_filter :set_twitter_oauth_client
def connect
request_token = @client.request_token
session[:twitter_request_token] = request_token.token
session[:twitter_request_token_secret] = request_token.secret
redirect_to request_token.authorize_url
end
require 'rubygems'
require 'sinatra'
require 'dm-core'
require 'net/http'
require 'uri'
class ImageModeration
include DataMapper::Resource
property :id, Integer, :serial=>true
property :image_url, Text