Skip to content

Instantly share code, notes, and snippets.

View tcocca's full-sized avatar

Tom Cocca tcocca

  • Boston Logic Technology Partners, Inc.
  • Boston, MA
View GitHub Profile
Upgrade System:
sudo apt-get update
sudo apt-get dist-upgrade
Standard Packages:
sudo apt-get install build-essential
Eye Candy:
Factory.define :application do |factory|
factory.attachment(:sample, "public/samples/sample.doc", "application/msword")
end
@tcocca
tcocca / rails_template.rb
Created October 4, 2009 17:31
My standard rails app template
# Tom's standard rails template
# Application Gems
gem "formtastic", :version => '>= 0.9.7'
gem 'will_paginate', :version => '~> 2.3.11'
gem "acts-as-taggable-on", :version => '>= 1.1.6'
gem "paperclip", :version => '>= 2.3.1.1'
gem "friendly_id", :version => '>= 2.3.2'
gem "inherited_resources", :version => '>= 1.1.0'
gem "thinking-sphinx", :lib => 'thinking_sphinx', :version => '>= 1.3.6'
# adapted from: http://github.com/railsmachine/shadow_puppet/blob/master/lib/shadow_puppet/core_ext.rb
require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/core_ext/array'
require 'active_support/inflector'
require 'active_support/core_ext/class/inheritable_attributes'
require 'active_support/core_ext/duplicable'
class Hash #:nodoc:
def update
@page = Page.find(params[:id[)
enforce_update_permission(@page) do
flash[:error] = "You can only edit your own pages"
redirect_to page_path(@page)
return
end
update!
end
class Tom
attr_accessor :handle
def initialize
@handle = "tomcocca"
end
end
page << <<-JS
var manager = $('office_manager_attr').value;
var office_admin = $('office_office_admin_attr').value;
var managers_arr = Array();
var office_admins_arr = Array();
managers_arr.push(new Option('', ''));
office_admins_arr.push(new Option('', ''));
JS
@agents.each do |agent|
page << <<-JS
class Post < ActiveRecord::Base
has_many :authors
has_many :post_comments
attr_accessor :post_authors_cache, :post_comments_cache
def post_authors
@post_authors_cache ||= begin
process_post
class Post < ActiveRecord::Base
has_many :authors
attr_accessor :post_authors_cache
def post_authors
process_post_authors if post_authors_cache.nil?
post_authors_cache
end
class Recipe < ActiveRecord::Base
belongs_to :style, :counter_cache => true
attribute_method_suffix '_previous_change'
private
def attribute_previous_change(attr)
self.changes[attr]