Skip to content

Instantly share code, notes, and snippets.

View dpickett's full-sized avatar

Dan Pickett dpickett

View GitHub Profile
@dpickett
dpickett / front_end.md
Created July 22, 2011 14:20
Front End Rails Apprentice

Come learn and grow with Enlight Solutions. It's a great opportunity to improve your coding skills and create awesome applications. This is a full time, contract to hire position. Initially, your work will focus on front end aspects of our clients' web applications.

Have you ever wanted to contribute to an application that will really help people find what they need? Currently, we're launching a network for cancer patients and their loved ones so that they can find better care, more support, and connections with others that have similar experience. We're anticipating heavy traffic volumes and usage as the client has partnered with American Cancer Society. This is truly a fun, rewarding project and an excellent client. There's some really interesting problems here around matching users with relevant peers, resources, events, and services among many others. Come solve them with us.

You will:

  • Learn design patterns and architectural techniques that help web applications scale and change with requirements
@dpickett
dpickett / intro_outline.txt
Created June 11, 2011 18:55
Course Outline for "Intro to Ruby and Object Oriented Programming"
Getting Started (Week 1)
Our Development Environment
IRB
The Command Line
Your Editor
Getting Help (Week 1)
Learn To Program
Ruby Documentation
Classmates
Teacher
@dpickett
dpickett / jquery.finder.js
Created June 10, 2011 17:12
finder menu for jquery
$.widget("ui.finder", {
// default options
options: {
columns: 3,
columnWidth: null,
height: 400,
hidden: true,
listSelector: "ul, ol"
},
def redirect_data
customer_options = {}
[
:first_name,
:last_name,
:email
].each do |prepopulate_attr|
if self.send(prepopulate_attr).present?
customer_options[prepopulate_attr] = self.send(prepopulate_attr)
end
@dpickett
dpickett / user_attr_accessible.rb
Created May 16, 2011 13:39
scoped mass assignment overview
class User < ActiveRecord::Base
belongs_to :group
attr_accessible :name
end
user = User.new(:name => "John", :group_id => 5)
user.attributes # {:name => "John", :group_id => nil} group_id is nil because it is not accessible
module IsModerated
def is_moderated(options = {})
after_save :deliver_moderation_mail, :on => :create
end
protected
def deliver_moderation_mail
#do the good stuff
end
end
begin
require "rcov"
namespace :rcov do
Cucumber::Rake::Task.new(:cucumber) do |t|
t.rcov = true
t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/,features\/ --aggregate coverage.data}
t.rcov_opts << %[-o "coverage"]
end
desc "Run all specs with rcov"
if Rails.env.production?
Braintree::Configuration.environment = Rails.env.staging? ? :sandbox : :production
Braintree::Configuration.merchant_id = ENV["braintree_merchant_id"]
Braintree::Configuration.public_key = ENV["braintree_public_key"]
Braintree::Configuration.private_key = ENV["braintree_private_key"]
else
Braintree::Configuration.environment = :sandbox
Braintree::Configuration.merchant_id = "<super secret>"
Braintree::Configuration.public_key = "<super secret>"
Braintree::Configuration.private_key = "<super secret>"
Destination Gateway Genmask Flags MSS Window irtt Iface
173.230.133.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.128.0 0.0.0.0 255.255.128.0 U 0 0 0 eth0
0.0.0.0 173.230.133.1 0.0.0.0 UG 0 0 0 eth0
Item.with_extended_attributes.order("created_at")
class Item < ActiveRecord::Base
has_one :car_attributes
has_one :dvd_attributes
def self.with_extended_attributes
#you could use some association introspection to build the list of includes
associations = [:dvd_attributes, :car_attributes]
includes(associations.map{|i| "LEFT JOIN #{i} ON items.id = #{i.to_s.tableize}.id"}.join(" "))