This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var alib = require('alib'); | |
| var blib = require('blib'); | |
| var clib = require('clib'); | |
| +var zlib = require('zlib'); | |
| var fruits = [ | |
| 'apples', | |
| 'bananas', | |
| 'cherries', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env coffee | |
| esprima = require 'esprima' | |
| isModule = (source) -> | |
| esprima.parse(source).body.some (node) -> | |
| node.type is 'ExpressionStatement' and | |
| node.expression.type is 'CallExpression' and | |
| node.expression.callee.type is 'Identifier' and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| concat = (lists...) -> | |
| [].concat(lists...) | |
| _traverse = (list, path, f) -> | |
| if list.length is 0 | |
| f(path) | |
| else | |
| for item, idx in list | |
| _traverse(concat(list.slice(0, idx), list.slice(idx + 1)), | |
| concat(path, [item]), f) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DATE | |
| TBD. Probably 2014-01-04 or 2014-01-05. | |
| VENUE | |
| TBD. Somewhere in Auckland, New Zealand. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| def memoize(f): | |
| memo = {} | |
| def wrapper(*args): | |
| if args not in memo: | |
| memo[args] = f(*args) | |
| return memo[args] | |
| return wrapper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ROUND 1 | |
| Darryn 2 v 0 James | |
| Dan 2 v 0 Matt | |
| Doug 0 v 2 David | |
| ROUND 2 | |
| Darryn 2 v 0 David | |
| James 2 v 1 Dan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FILES = ( | |
| 'foo.txt', | |
| 'bar.txt', | |
| 'baz.txt', | |
| ) | |
| def getmetadata(path): | |
| return {'blah': True, 'quux': 42} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| express = require 'express' | |
| app = express() | |
| app.param (name, arg) -> switch Object::toString.call arg | |
| when '[object RegExp]' | |
| (req, res, next, val) -> | |
| if arg.test val then next() else next 'route' |
- avoid unnecessary state
- favor pure functions over impure functions
- functions should not have surprising side effects
- give things meaningful names, and avoid aliases
- don't swallow unexpected errors