Skip to content

Instantly share code, notes, and snippets.

@ericallam
ericallam / package.mdown
Created January 12, 2012 15:18
Use versioned github tarballs to update dependencies on heroku cedar stack

Heroku cedar stack lets you deploy node.js apps and uses the npm package manager to install dependencies When pushing to heroku, it will install dependencies using npm install, and heroku helpfully caches your dependencies between deploys. This can be a problem when you update a dependency that uses a github tarball, like this:

// package.json
{
  "name": "node app name",
  "description": "",
  "version": "0.0.1",
 "dependencies": {
@ericallam
ericallam / generated.js
Created February 8, 2012 14:09
Comparing js and coffeescript
(function() {
var TodosView,
__hasProp = Object.prototype.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
TodosView = (function(_super) {
__extends(TodosView, _super);
function TodosView() {
@ericallam
ericallam / todo.js
Created February 8, 2012 14:16
How do you handle a collection's remove event in a collection view?
var TodoItem = Backbone.Model.extend({});
var TodoView = Backbone.View.extend({
template: _.template('<h3><%= description %></h3>'),
initialize: function(){
this.model.bind('change', this.render, this);
this.model.on('destroy', this.remove, this);
},
@ericallam
ericallam / app.js
Created February 8, 2012 18:44
debouncing save
var TodoItem = Backbone.Model.extend({
initialize: function(){
this.save = _.debounce(this.save, 500);
},
toggleStatus: function(){
if(this.get('status') == 'incomplete'){
this.set({'status': 'complete'});
}else{
this.set({'status': 'incomplete'});
@ericallam
ericallam / model_defaults.js
Created March 2, 2012 16:26
backbone model defaults with a function
var Appointment = Backbone.Model.extend({
defaults: function(){
date: new Date()
}
});
var app1 = new Appointment();
var app2 = new Appointment();
app1.get('date') !== app2.get('date')
@ericallam
ericallam / phantom-demo.coffee
Created March 8, 2012 19:47
phantomjs security exception when using evaluate without first using open
page = new WebPage()
page.viewportSize = { width: 800, height: 800 }
page.content = "<html><head><title></title></head><body><div></div></body></html>"
page.onConsoleMessage = (msg) ->
console.log msg
page.evaluate ->
console.log window.location.protocol # about:
@ericallam
ericallam / commits.txt
Created April 2, 2012 21:34
A sample of commits from the lolcode.codeschool.com project
commit 79d8497573031a08cffa5bf7d844586aa86d9483
Author: Eric Allam
Date: Sat Mar 31 12:43:45 2012 -0400
FIXIN YR SPECS
commit 88e9343e1e06956473462a4a83fed7e8e3c845b4
Author: Nick Walsh
Date: Fri Mar 30 12:07:23 2012 -0400
@ericallam
ericallam / application.css
Created May 1, 2012 18:32
Rails generated manifest files
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
@ericallam
ericallam / gist:2855197
Created June 1, 2012 21:20
All ActiveSupport::Notifications that Rails instruments
receive.action_mailer
deliver.action_mailer
write_fragment.action_controller
read_fragment.action_controller
exist_fragment?.action_controller
expire_fragment.action_controller
write_page.action_controller
expire_page.action_controller
start_processing.action_controller
process_action.action_controller
@ericallam
ericallam / speaker.md
Created June 10, 2012 22:04 — forked from matiaskorhonen/speaker.md
Frozen Rails Talk Proposal Template (http://2012.frozenrails.eu/)