Skip to content

Instantly share code, notes, and snippets.

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
@epoch
epoch / link_to.rb
Created January 12, 2011 21:27 — forked from emk/link_to.rb
@epoch
epoch / photo.rb
Created January 12, 2011 21:28 — forked from achiurizo/photo.rb
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
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
  • 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

#MAC WDI-Installfest


##Homebrew

###Install Homebrew

class ApplicationController < ActionController::Base
protect_from_forgery
protected
def current_user
@current_user ||= User.find_by_id(session[:user_id])
end
def signed_in?
@epoch
epoch / ruby_arrays.md
Last active December 7, 2021 03:28
arrays

1. Create an array of the days of the week

  • Create a variable named days_of_the_week as an array of the following:
    • Sunday
    • Monday
    • Tuesday
    • Wednesday
    • Thursday
    • Friday
    • Saturday
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
@epoch
epoch / 0_reuse_code.js
Created March 5, 2014 13:47
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console