Skip to content

Instantly share code, notes, and snippets.

View zeppelin's full-sized avatar
🐹

Gabor Babicz zeppelin

🐹
View GitHub Profile
module PythonishDecorator
def method_added(name)
return unless @decorations
decorations = @decorations.dup
@decorations = nil
alias_method "undecorated_#{name}", name
define_method(name) do |*args|
@wrs
wrs / DeviseJsonAdapter.rb
Created December 8, 2010 18:02
JSON-encoded error and redirect results for Devise controllers
# JSON-encoded error and redirect results for Devise controllers.
# This overrides an internal method of Devise, so be careful when updating Devise!
#
# Usage:
#
# class Users::RegistrationsController < Devise::RegistrationsController
# include DeviseJsonAdapter
# end
#
# devise_for :users, :controllers => { :registrations => "users/registrations" }
@mathieul
mathieul / gist:966776
Created May 11, 2011 16:12
Require files using RequireJS before running Jasmine specs
/*
* jasmine.requirejs() returns a function that will load the file(s) required
* and will wait until it's done before proceeding with running specs.
* The function returned is intended to be passed to beforeEach() so the file(s)
* is(are) loaded before running each spec.
*
* Syntax:
*
* jasmine.requirejs(options, files)
* or
@elffey
elffey / controllers--menu.js
Created May 27, 2011 18:48
Simple navigation/routes/statechart
MyApp.menuController = SC.ArrayController.create({
allowsEmptySelection: NO,
allowsMultipleSelection: NO,
content: [
SC.Object.create({
name: 'Dashboard',
route: 'dashboard',
@stefri
stefri / template_changing_view.js
Created May 28, 2011 15:44
SC.TemplateChangingView
SC.TemplateChangingView = SC.TemplateView.extend(
/** @scope SC.TemplateChangingView.prototype */{
templateNameDidChange: function() {
SC.Logger.debug("Template name was set to " + this.get('templateName'));
this.rerender();
}.observes('template'),
/**
Called when the template property associated with this view changes.
class InfoDesk
def trains
:trains
end
def flights
:flights
end
def buses
:buses
end
@hoverlover
hoverlover / active_admin_heroku.rb
Created June 7, 2011 16:35
Rails initializer for using ActiveAdmin with Sass on Heroku
if Rails.env.production?
require 'fileutils'
FileUtils.mkdir_p(Rails.root.join("tmp", "stylesheets", "admin"))
template_path_one = "#{Gem.loaded_specs['activeadmin'].full_gem_path}/app/assets/stylesheets"
template_path_two = "#{Gem.loaded_specs['activeadmin'].full_gem_path}/lib/active_admin/sass"
old_compile_path = "#{Rails.root}/public/stylesheets/admin"
new_compile_path = "#{Rails.root}/tmp/stylesheets/admin"
Sass::Plugin::remove_template_location template_path_one
@tomdale
tomdale / gist:1134558
Created August 9, 2011 16:53
Load remote Handlebars templates
jQuery.get('/templates/foo.handlebars', function(data) {
var template = SC.Handlebars.compile(data);
SC.TEMPLATES['foo'] = template;
})
@mislav
mislav / Gemfile
Created August 31, 2011 21:48
How to integrate Compass with Rails 3.1 asset pipeline
group :assets do
gem 'sass-rails', '~> 3.1.0'
gem 'coffee-rails', '~> 3.1.0'
gem 'uglifier'
gem 'compass'
end
@kaelig
kaelig / Gemfile
Created September 7, 2011 00:20
Sass & CoffeeScript automated compiling and minifying with Guard
source "http://rubygems.org"
group :development do
gem 'rake'
gem 'guard'
gem 'coffee-script'
gem 'rb-fsevent'
gem 'rb-inotify'
gem 'compass', '0.11.5'
gem 'sass', '3.1.5'
gem 'guard-compass'