CoffeeScript makes this work well:
[name, age] = user.get('name', 'age')
It would be trivially easy to allow Pam.Model
's get
to override Backbone's get
to support this
# There's an incredibly common pattern when using promises: | |
# | |
# myFunction: -> | |
# dfd = $.Deferrred() | |
# | |
# $.ajax "wherever" | |
# .done() -> | |
# dfd.resolve("yep") | |
# .fail() -> | |
# dfd.reject("nope") |
A short list of CoffeeScript gotcha's I've encountered writing CoffeeScript professionally.
These are not problems with CoffeeScript, rather they are strange one-off situations where, especially coming from Ruby, differences in CoffeeScript's syntax have led to unexpected JavaScript.
Jarrod Overson's excellent QConSF 2013 talk
Original slides: http://www.slideshare.net/JarrodOverson/complexity-28214103
Matthew "Maverick" Eagar
# Use: | |
# | |
# # Pass an emuerable to #new | |
# | |
# users = User.active | |
# RakeProgrssBar.new(users) do |user| | |
# user.do_something_amazing | |
# end | |
# | |
# |
Note: this presentation was written for Gistdeck. Add the bookmarklet, come back to this gist, click the bookmarklet, then use the arrow keys to navigate.
Note2: See https://github.com/meagar/taking-javascript-offline for code examples; any time a string like 2-basic-caching
appears, that's a branch which supports that slide
$ git checkout web-123-my-branch # make sure you're on the right branch
$ git fetch # update remote refs
$ git rebase origin/master # perform the rebase onto the current state of master
# for each conflict, edit file, resolve conflicts, git add -u <file>, git rebase --continue
$ git push -f origin web-123-my-branch # overwrite remote branch with newly rebase branch
#!/usr/bin/env ruby | |
# | |
# This is a Git pre-commit hook. | |
# | |
# Reject commits that contain any of the following strings: | |
# # NO COMMIT | // NO COMMIT | #NOCOMMIT | //NOCOMMIT | etc | |
# debugger | |
# binding.pry | |
# console.log |
require 'time' | |
DAY = 60 * 60 * 24 | |
def print_branches(branches) | |
by_author = Hash.new { |hash,key| hash[key] = {} } | |
branches.each do |branch| | |
lines = `git show -s --pretty=medium #{branch}`.lines | |
# commit d8f1e9d4c755d46192db635e964a9b04d6882f90 |
I hereby claim:
To claim this, I am signing this object: