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
#!/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:
// ---- | |
// Sass (v3.4.12) | |
// Compass (v1.0.3) | |
// ---- | |
.loggedIn | |
margin: 0 | |
&.active | |
margin: auto |