Skip to content

Instantly share code, notes, and snippets.

@mislav
mislav / readme.md
Created January 25, 2012 14:42
CLI tool that checks the build status of current branch on Travis CI

Check build status of a project on the command line

Install (copy & paste):

curl -sL raw.github.com/gist/1676577/travis.rb > ~/bin/travis \
  && chmod +x ~/bin/travis

gem install hub | tail -2
ruby -e 'require "json"' 2>/dev/null || gem install json
@wagenet
wagenet / Assetfile.rb
Created January 13, 2012 20:37
Ember Handlebars Precompile
require 'execjs'
class HandlebarsFilter < Filter
class << self
def contents
@@contents ||= [File.read("headless-ember.js"), File.read("ember.js")].join("\n")
end
def context
@@context ||= ExecJS.compile(contents)
@cowboy
cowboy / ba-backbone-module.js
Created September 9, 2011 18:05
Idea for a Backbone module system (allowing modules to be accessed across multiple files, possibly loaded out of order). Inspired by https://gist.github.com/1202511
/*!
* Backbone Module Manager - v0.1pre - 9/9/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
function ModuleManager(fn) {
@chriseppstein
chriseppstein / readme.md
Created August 31, 2011 21:57 — forked from mislav/Gemfile
How to integrate Compass with Rails 3.1 asset pipeline

This gist is no longer valid. Please see Compass-Rails for instructions on how to install.

@a-chernykh
a-chernykh / application_controller.rb
Created June 22, 2011 19:43
devise force https for sign in and sign up routes
class ApplicationController < ActionController::Base
before_filter :ensure_proper_protocol
protected
def ssl_allowed_action?
(params[:controller] == 'users/sessions' && ['new', 'create'].include?(params[:action])) ||
(params[:controller] == 'users/registrations' && ['new', 'create', 'edit', 'update'].include?(params[:action])) ||
(params[:controller] == 'users/omniauth_callbacks')
end
require 'sinatra'
require 'omniauth'
class Application < Sinatra::Base
use OmniAuth::Builder do
provider :github, 'github_id', 'github_secret'
end
get '/' do
@trydionel
trydionel / backbone.rails.js
Created November 28, 2010 16:47
Makes Backbone.js play nicely with default Rails setup
//
// Backbone.Rails.js
//
// Makes Backbone.js play nicely with the default Rails setup, i.e.,
// no need to set
// ActiveRecord::Base.include_root_in_json = false
// and build all of your models directly from `params` rather than
// `params[:model]`.
//
// Load this file after backbone.js and before your application JS.
package_assets: on # (on, off, always)
embed_assets: on # (on, off, datauri)
compress_assets: on # (on, off)
gzip_assets: on # (on, off)
template_function: _.template # (defaults to the built-in micro-templating)
package_path: packages # (defaults to assets)
javascript_compressor: closure # (yui, closure)
compressor_options:
compilation_level: ADVANCED_OPTIMIZATIONS
# You should define those models. (you can change the model names)
#
# * Oauth2::Client
# * Oauth2::AccessToken
# * Oauth2::RefreshToken
# * Oauth2::AuthorizationCode
class Oauth2Controller < ApplicationController
before_filter :require_authentication, :only => :authorize
# environment.rb
#
# These are models you should define. (you can change the model name, of course)
# * Oauth2::AccessToken
Rails::Initializer.run do |config|
:
require 'rack/oauth2'
oauth2_authenticator = lambda do |request|
access_token = Oauth2::AccessToken.find_by_token(request.access_token)