Skip to content

Instantly share code, notes, and snippets.

View iwasrobbed's full-sized avatar
:shipit:
"1 billion years".Save()

rob phillips iwasrobbed

:shipit:
"1 billion years".Save()
View GitHub Profile
class ImageUploader < CarrierWave::Uploader::Base
# include MiniMagick support for resizing images
include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
# (handled in the initializer file)
# storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
@iwasrobbed
iwasrobbed / gist:1032395
Created June 17, 2011 21:29
Amazon S3 Query String Authentication for Ruby on Rails
def generate_secure_s3_url(s3_key)
#
# s3_key would be a path (including filename) to the file like: "folder/subfolder/filename.jpg"
# but it should NOT contain the bucket name or a leading forward-slash
#
# this was built using these instructions:
# http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?S3_QSAuth.html
# http://aws.amazon.com/code/199?_encoding=UTF8&jiveRedirect=1
s3_base_url = MyApp::Application::S3_BASE_URL # i.e. https://mybucket.s3.amazonaws.com
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="SOAPAction">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" secure="false" />
</cross-domain-policy>
class ImportController << ApplicationController
require 'net/http'
require 'net/https'
require 'uri'
#THIS METHOD TO SEND USER TO THE GOOGLE AUTHENTICATION PAGE.
def authenticate
# initiate authentication w/ gmail
# create url with url-encoded params to initiate connection with contacts api
@iwasrobbed
iwasrobbed / gist:906235
Created April 6, 2011 18:37
Infinite scrolling modified for ajax
function kickOffAjax(){
// we dont want to fire the ajax multiple times
opts.isDuringAjax = true;
// show the loading message quickly
// then hide the previous/next links after we're
// sure the loading message was visible
props.loadingMsg.appendTo( opts.loadMsgSelector ).show(opts.loadingMsgRevealSpeed, function(){
$( opts.navSelector ).hide();
root /(.:format) {:controller=>"users", :action=>"new"}
sessions POST /sessions(.:format) {:action=>"create", :controller=>"sessions"}
new_session GET /sessions/new(.:format) {:action=>"new", :controller=>"sessions"}
session DELETE /sessions/:id(.:format) {:action=>"destroy", :controller=>"sessions"}
user_favorite GET /users/:user_id/favorites/:id(.:format) {:action=>"show", :controller=>"favorites"}
PUT /users/:user_id/favorites/:id(.:format) {:action=>"update", :controller=>"favorites"}
user_profile GET /users/:user_id/profile/:id(.:format) {:action=>"show", :controller=>"profile"}
PUT /users/:user_id/profile/:id(.:format) {:action=>"update", :controller=>"profile"}
= link_to "Link name",
{ :controller => 'controller_name', :action => 'action_name' },
:class => 'someclass'
= link_to "Sign out", signout_path,
:method => :delete,
:class => "nohover tl light"
#config/initializers/requires.rb
Dir[File.join(Rails.root, 'lib', '*.rb')].each do |f|
require f
end