Skip to content

Instantly share code, notes, and snippets.

View acorcutt's full-sized avatar
Making Stuff

Anthony Corcutt acorcutt

Making Stuff
View GitHub Profile
SecureRandom.uuid
@acorcutt
acorcutt / jquery.myplugin.js
Created June 28, 2011 16:42
JQuery Plugin Starter
// JQuery Plugin Starter
// ----------------------------------------------------
// Setup a namespace we can use for data, events etc.
// Wraps methods internally with support for arguments.
//
// $('div').myplugin(); //call init
// $('div').myplugin({color:'green'}).fadeIn(); //init with options and chained
// $('div').myplugin('destroy'); //custom method
// $('div').myplugin('custom',10,2); //custom method with arguments
//
@acorcutt
acorcutt / gist:1043559
Created June 23, 2011 20:31
Turn Safari Plugins (Flash) On|Off Command
defaults read com.apple.Safari WebKitPluginsEnabled
defaults write com.apple.Safari WebKitPluginsEnabled -boolean true | false
defaults write com.apple.Safari WebKitPluginsEnabled 0 | 1
#instead of
current_user && current_user.admin?
#do
current_user.try(:admin?)
@acorcutt
acorcutt / application.rb
Created June 1, 2011 22:35
Turn off fixture creation
config.generators do |g|
g.fixture false
end
@acorcutt
acorcutt / providers_controller.rb
Created April 3, 2011 14:46
Rails twitter login
#a simple controller to login with twitter
#add gem 'oauth' to gemfile
#setup a route to /twitter => #show and /twitter/callback => #callback
class TwittersController < ApplicationController
def consumer
#return a consumer for twitter, add you key and secret here or dynamically grab from db etc.
OAuth::Consumer.new(
"key",
"secret",
:site => "https://api.twitter.com",
@acorcutt
acorcutt / RailsProxy.pac
Created January 5, 2011 17:59
This makes testing with domains and sub-domains easier on a mac, choose "Automatic Proxy Configuration" in Airport settings and set the URL to this file. Then any request to port 3000 will be pointed to the local rails server e.g. http://sub.mydomain.c
function FindProxyForURL(url, host) {
var port = url.match(/^\w{3,5}:\/\/[^:\/]*(:(\d+))?/)[2];
if(port){
if(port=="3000"){
var proxy = "PROXY localhost";
if(port){proxy += ":" + port;}
return proxy;
}
}