Skip to content

Instantly share code, notes, and snippets.

View timbertson's full-sized avatar

Tim Cuthbertson timbertson

View GitHub Profile
# defer can be placed in front of any function call that takes
# a callback as its last paramater.
# instead of this:
myFunc: (callback) ->
someFunction 1, 2, 3, (result) ->
doSomeThingWith(result)
callback(true)
# you will write this:
class Sync
constructor: (reader, store) ->
@reader = reader
@store = store
pull_tags: (cb) ->
@reader.get_user_tags (tags) ->
@store.set_valid_tags(tags, cb)
pull_items: (tag_name, cb) ->
(function(){
var _a, _b, _c, _d, evens, num;
evens = (function() {
_a = []; _c = [1, 2, 3, 4, 5, 6];
for (_b = 0, _d = _c.length; _b < _d; _b++) {
num = _c[_b];
num % 2 === 0 ? _a.push((function() {
num *= -1;
num -= 2;
return num * -1;
diff --git a/src/grammar.coffee b/src/grammar.coffee
index 0a8d950..219911d 100644
--- a/src/grammar.coffee
+++ b/src/grammar.coffee
@@ -457,8 +457,8 @@ grammar: {
# The CoffeeScript switch/when/else block replaces the JavaScript
# switch/case/default by compiling into an if-else chain.
Switch: [
- o "SWITCH Expression INDENT Whens OUTDENT", -> $4.rewrite_condition $2
- o "SWITCH Expression INDENT Whens ELSE Block OUTDENT", -> $4.rewrite_condition($2).add_else $6, true
exports.run_tests: run_tests: (cb) ->
remaining: (test for test in tests when test.success is null)
iterate: ->
if remaining.length == 0
cb()
return
test: remaining.shift()
test.run(iterate)
iterate()
$ bin/cake test -f operations
passed 3 tests in 0.01 seconds
# verbose test listing
# basically, you just have nested "describe" blocks, with one "it" block per test.
describe 'deferred', ->
it 'should deal with a single defer', ->
single_def: (x) -> defer return_arg(x)
equal single_def.length, 2
callback_called: false
single_def "a", (result) ->
@timbertson
timbertson / etcd-ca-disable-p224.patch
Created August 28, 2014 00:10
etcd-ca-disable-p224.patch
diff --git a/pkcs10.go b/pkcs10.go
index a257e20..6550702 100644
--- a/pkcs10.go
+++ b/pkcs10.go
@@ -169,9 +169,9 @@ func CreateCertificateSigningRequest(rand io.Reader, template *CertificateSignin
publicKeyAlgorithm.Algorithm = oidPublicKeyRSA
case *ecdsa.PrivateKey:
switch priv.Curve {
- case elliptic.P224(), elliptic.P256():
- hashFunc = crypto.SHA256