Skip to content

Instantly share code, notes, and snippets.

View derrickko's full-sized avatar

Derrick Ko derrickko

  • San Francisco
View GitHub Profile
@derrickko
derrickko / view_manager.coffee
Created June 25, 2012 21:54
Backbone View Manager
class ViewManager
containerId: "#mainContent"
constructor: ->
@container = $(@containerId)
@currentView = null
@modalView = null
Backbone.View::close = ->
@remove()
@unbind()
@derrickko
derrickko / controller.rb
Created June 25, 2012 19:07
Action caching helpers
caches_action :index, :cache_path => Proc.new {
cache_key_for_relation(current_user.received_deliveries)
}
def cache_key_for_relation(relation, order_clause)
relation = relation.reorder(order_clause)
count = relation.count
if count > 0
cache_key_for "#{relation.first.cache_key}-#{count}"
@derrickko
derrickko / Gemfile
Created April 6, 2012 02:43
Using Twitter Bootstrap with Rails 3.1 and SASS
gem "less", "~> 2.0.6"