Skip to content

Instantly share code, notes, and snippets.

@JamesHayton
JamesHayton / gist:1862587
Created February 19, 2012 08:15 — forked from jacquescrocker/gist:1318784
google cloud print pointers
# this works with oauth 0.5.1
client = OAuth2::Client.new(CLIENT_ID, CLIENT_SECRET,
:authorize_url => "/o/oauth2/auth",
:token_url => "/o/oauth2/token",
:site => 'https://accounts.google.com/')
redirect_uri = "#{SERVER_URL}/oauth2callback"
get '/auth' do
@JamesHayton
JamesHayton / rails content_for caching
Created February 14, 2012 04:44 — forked from stackng/rails content_for caching
make action and fragment caching of rails3 compatible with content_for
module ActionController
class Metal
attr_internal :cached_content_for
end
module Caching
module Actions
def _save_fragment(name, options)
return unless caching_allowed?
class BaseModel < CouchRest::ExtendedDocument
include ActiveModel::Dirty
use_database DB
def initialize(passed_keys={}, options={})
super(passed_keys, options)
@changed_attributes = {}
end
class <<self
require "rubygems"
require "faker"
require "couchrest"
DB = CouchRest.database!('http://127.0.0.1:5984/contacts')
class Contact < CouchRest::ExtendedDocument
use_database DB
property :first_name
<% if can? :destroy, @comment %>
<%= link_to 'Delete', comment_path({:id => comment.id}), :confirm => "Are you sure?", :method => :delete %>
<% end %>
require 'couchrest'
class Log < CouchRest::ExtendedDocument
database = CouchRest.new
database.default_database = "logger"
use_database database.default_database
property :response_time
property :created_at
{
"all": {
"map": "function(doc) {\n if (doc['couchrest-type'] == 'BlogUser') {\n emit(doc['_id'],1);\n }\n }"
},
"by_account": {
"map": "function(doc) {\n if ((doc['couchrest-type'] == 'BlogUser') && doc['account']) {\n emit(doc['account'], null);\n }\n}\n"
}
}
# Installing Rails 3.0.pre in it's own gemset using rvm.
# I use Ruby Enterprise Edition for rails development.
# You might want to replace ree with Your Favorite Ruby Implementation(tm)
rvm use ree%rails3 # Create new gemset called rails3.
gem install rake rack test-spec thor sqlite3-ruby # Get some gems we'll need (rails3 gemset should be empty)
git clone git://github.com/rails/rails.git && cd rails # Get rails source.
git submodule init && git submodule update # Get git dependencies.
rake package && gem install -f */pkg/*.gem pkg/*.gem # Create gems and install
cd arel && thor :build && thor :install && cd ../.. # Install arel
SC.PoolableClass = {
isPooled: YES,
_objectPool: [],
maxPoolSize: 100,
_pool_default_concat_values: {}, // default values for concatenated properties
create: function() {
// first, check pool