Skip to content

Instantly share code, notes, and snippets.

View micahroberson's full-sized avatar

Micah Roberson micahroberson

View GitHub Profile
@micahroberson
micahroberson / gist:9420417
Last active August 29, 2015 13:57
Backbone Layout Manager View
define [
'jquery'
'underscore'
'backbone'
'models/session'
'text!templates/sessions/new.html'
], ($, _, Backbone, Session, template) ->
SessionsNewView = Backbone.View.extend
template: _.template(template)
@micahroberson
micahroberson / estimate.rb
Created July 13, 2013 00:35
Generate and save a pdf to S3 with wicked_pdf and paperclip
# Main reference was lascarides' post at http://stackoverflow.com/questions/14743447/getting-pdf-from-wickedpdf-for-attachment-via-carrierwave
# estimate.rb
# ...
has_attached_file :pdf,
storage: :s3,
s3_credentials: {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
bucket: ENV['AWS_BUCKET']
@micahroberson
micahroberson / HashCollection.coffee
Last active December 16, 2015 20:29
Backbone Collection extension to maintain hash of models on attributes or user-defined functions
class BaseCollection extends Backbone.Collection
initialize: () ->
@_hash_keys = {}
# @hashOn 'last_name', false
# Start hashing on passed in attribute or method on the model that returns a string
# unique indicates whether or not mulitple models in the collection have the same value for this attribute
# If unique is true, we'll keep track of all models with the same value instead of overwriting in the store
hashOn: (key, unique) ->