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
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; | |
} | |
} |
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
#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", |
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
config.generators do |g| | |
g.fixture false | |
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
#instead of | |
current_user && current_user.admin? | |
#do | |
current_user.try(:admin?) |
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
defaults read com.apple.Safari WebKitPluginsEnabled | |
defaults write com.apple.Safari WebKitPluginsEnabled -boolean true | false | |
defaults write com.apple.Safari WebKitPluginsEnabled 0 | 1 |
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
// 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 | |
// |
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
SecureRandom.uuid |
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
<%-# items is an array on object e.g. object.items = [1,2,3], we want to display as list of fields, and post back as an array - note the backwards ][ which makes is do this! -%> | |
<% @object.items.each do |i| %> | |
<%=f.text_field "items][",:value=>i,:id=>"item-#{SecureRandom.uuid}" %> | |
<% 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
module Indexer | |
# Add indexed fields to model | |
# TODO - make this work in embedded e.g. self.index_embedded(*names) | |
module Indexes | |
extend ActiveSupport::Concern | |
included do | |
class_attribute :_index_fields | |
class_attribute :_index_texts |
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
// Instead of copying js plugins to assets/ import them from a url. | |
// Obviously works best with pre-compiled assets | |
<%=open('https://raw.github.com/documentcloud/backbone/master/backbone.js | |
').read%> |
OlderNewer