Skip to content

Instantly share code, notes, and snippets.

View CodeOfficer's full-sized avatar

Russell Jones CodeOfficer

View GitHub Profile
# courtesy of http://heypanda.com/
class TryProxy
def initialize(receiving_object)
@receiving_object = receiving_object
end
def method_missing(meth, *args, &block)
@receiving_object.nil? ? nil : @receiving_object.send(meth, *args, &block) rescue nil
end
posts GET /posts {:controller=>"posts", :action=>"index"}
formatted_posts GET /posts.:format {:controller=>"posts", :action=>"index"}
POST /posts {:controller=>"posts", :action=>"create"}
POST /posts.:format {:controller=>"posts", :action=>"create"}
new_post GET /posts/new {:controller=>"posts", :action=>"new"}
formatted_new_post GET /posts/new.:format {:controller=>"posts", :action=>"new"}
/*
NAME: Russell Jones
DATE: February 21, 2007
PROJECT: LinSprite
FILE: GamePanel.java
*/
package linsprite;
import java.awt.Color;
alias home='cd ~/'
alias ll='ls -lAGhF'
alias tld='tail -f log/development.log'
alias tlp='tail -f log/production.log'
alias ss='script/server'
alias ssd='script/server --debugger'
alias ssp='script/server -e production'
alias sc='script/console'
alias scs='script/console --sandbox'
alias sg='script/generate'
require '../lib/liquid'
class User
attr_accessor :name
liquid_methods :name
def initialize(name)
@name = name
end
end
@CodeOfficer
CodeOfficer / gist:70314
Created February 25, 2009 17:48
jays presenter pattern
# from: http://pastie.org/47453
# http://blog.jayfields.com/2007/03/rails-presenter-pattern.html
class CompletePresenter < Presenter
presentable :account, UserAccount.new
presentable :address, Address.new
presentable :credential, UserCredential.new
def save
# Install logrotate on OS X:
# sudo port clean --all logrotate && sudo port install logrotate
# Add e.g. this to your crontab:
# /opt/local/sbin/logrotate -s /Users/deploy/.logrotate/sites.status /Users/deploy/.logrotate/sites.conf
# This file would be sites.conf.
# See http://overstimulate.com/articles/logrotate-rails-passenger for more info.
daily
missingok
rotate 30
# SUPER DARING APP TEMPLATE 1.0
# By Peter Cooper
# Link to local copy of edge rails
inside('vendor') { run 'ln -s ~/dev/rails/rails rails' }
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
class Page < ActiveRecord::Base
acts_as_taggable_on :tags
has_many :containers, :as => :containable, :dependent => :destroy, :order => "position"
has_many :comments, :as => :commentable, :dependent => :destroy
before_validation :generate_slug
before_validation :set_dates
class CreateTextContainers < ActiveRecord::Migration
def self.up
create_table :text_containers do |t|
t.string :formatting
t.text :body
t.boolean :is_published
t.boolean :is_initial_record, :default => true
# ... and all the other revisable fields
t.timestamps
end