Skip to content

Instantly share code, notes, and snippets.

View mbleigh's full-sized avatar

Michael Bleigh mbleigh

View GitHub Profile
GameRouter = new Backbone.Router.extend
routes:
"start": "start"
"draw": "draw"
start: ->
this.navigate('/draw')
draw: ->
$('#sketchpad .front > div').hide()
$('#draw').show()
#count {
color: #aaa;
font-family: "Lucida Grande", "Lucida Sans", sans-serif;
}
@mbleigh
mbleigh / Gemfile
Created September 28, 2011 16:08
How to use OmniAuth 1.0 RIGHT. NOW.
gem 'sinatra'
gem 'omniauth', '~> 1.0.0.alpha', :git => 'git://github.com/intridea/omniauth.git'
gem 'omniauth-oauth', '~> 1.0.0.alpha', :git => 'git://github.com/intridea/omniauth-oauth.git'
gem 'omniauth-contrib', '~> 1.0.0.alpha', :git => 'git://github.com/intridea/omniauth-contrib.git'
@mbleigh
mbleigh / gist:1384828
Created November 22, 2011 03:39 — forked from jch/gist:1384826
Object.pathy!
def response
last_response.stub!(:parsed_body).and_return(MultiJson.decode(last_response.body))
last_response
end
def body(path = nil)
if path
response.parsed_body.at_json_path(path)
@mbleigh
mbleigh / .gitignore
Created December 4, 2011 01:57
MongoMapper::TokenKeys, a simple way to generate tokens for MongoMapper models.
Gemfile.lock
class API < Grape::API
version '1'
end
Rack::Builder.new do
use Rack::Cors do |config|
config.allow do |allow|
allow.origins '*'
allow.resource '*', :headers => :any
end
class User
attr_reader :item
def self.create(name)
User.new(TABLES['users'].items.create(id: name))
end
def self.all
TABLES['users'].items.to_a.map{|i| User.new(i)}
end
MyClass
This class is a simple class that does things. Notice that I'm
just using it as an example for potential documentation style.
.class_method
Does something at the class level.
@param options [Hash] A hash of options
.new
Creates a new instance of MyClass
@mbleigh
mbleigh / Gemfile
Created March 21, 2012 03:14
Non-Rails Rackup with Sprockets, Compass, Handlebars, Coffeescript, and Twitter Bootstrap
source "https://rubygems.org"
gem 'sprockets'
gem 'sprockets-sass'
gem 'sass'
gem 'compass'
gem 'bootstrap-sass'
gem 'handlebars_assets'
gem 'coffee-script'
@mbleigh
mbleigh / bouncy.rb
Created March 29, 2012 15:31
A rough and naive declarative syntax for class reloading.
module Bouncy
def self.mappings
@@mappings ||= []
end
def self.bounce!
mappings.each(&:bounce!)
end
def self.runner(const_name)