- favour clarity even if it means more lines of code
- write code for people first
- unix single reponsibility principle
- minimize non presentation logic in templates
- alignments of code
- data model design, less than ideal naming in model, names matter
- reduce roundtrips to the database
- semantic css
- it is ok to have multiple css files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby-1.9.1-p378 > s3 = RightAws::S3.new('44CF9590006BF252F707','OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV', :server => 'localhost', :protocol => 'http', :port => 3002) | |
I, [2010-08-11T09:17:55.795019 #3084] INFO -- : New RightAws::S3Interface using shared connections mode | |
=> #<RightAws::S3:0x0000000381aeb8 @interface=#<RightAws::S3Interface:0x0000000381ae80 @params={:server=>"localhost", :protocol=>"http", :port=>3002, :service=>"/", :connections=>:shared, :max_connections=>10, :connection_lifetime=>1200, :api_version=>nil}, @aws_access_key_id="44CF9590006BF252F707", @aws_secret_access_key="OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV", @logger=#<Logger:0x0000000381ac18 @progname=nil, @level=0, @default_formatter=#<Logger::Formatter:0x0000000381abe0 @datetime_format=nil>, @formatter=nil, @logdev=#<Logger::LogDevice:0x0000000381ab70 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x0000000381ab38 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x0000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
helpers do | |
# Construct a link to +url_fragment+, which should be given relative to | |
# the base of this Sinatra app. The mode should be either | |
# <code>:path_only</code>, which will generate an absolute path within | |
# the current domain (the default), or <code>:full_url</code>, which will | |
# include the site name and port number. The latter is typically necessary | |
# for links in RSS feeds. Example usage: | |
# | |
# link_to "/foo" # Returns "http://example.com/myapp/foo" | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'carrierwave/orm/mongoid' | |
class Photo | |
include Mongoid::Document | |
include Mongoid::Timestamps # adds created_at and updated_at fields | |
# fields | |
field :caption, :type => String | |
mount_uploader :file, Uploader | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Warden::Manager.serialize_into_session{|user| user.id } | |
Warden::Manager.serialize_from_session{|id| User.get(id) } | |
Warden::Manager.before_failure do |env,opts| | |
# Sinatra is very sensitive to the request method | |
# since authentication could fail on any type of method, we need | |
# to set it for the failure app so it is routed to the correct block | |
env['REQUEST_METHOD'] = "POST" | |
end | |
#MAC WDI-Installfest
##Homebrew
###Install Homebrew
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
protected | |
def current_user | |
@current_user ||= User.find_by_id(session[:user_id]) | |
end | |
def signed_in? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ClassMethods | |
def find_for_oauth(auth) | |
record = where(provider: auth.provider, uid: auth.uid.to_s).first | |
record || create(provider: auth.provider, uid: auth.uid, email: auth.info.email, password: Devise.friendly_token[0,20]) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
OlderNewer