Skip to content

Instantly share code, notes, and snippets.

# client = ...
class User
constructor: (call_when_created) ->
m = client.multi()
m.incr "user_id"
m.get "user_id", (e, r) ->
@id = parseInt r, 10
$ npm install docco
npm info it worked if it ends with ok
npm info using npm@0.3.7
npm info using node@v0.4.0
npm ERR! Error parsing json /usr/local/lib/node/.npm/docco/0.3.0/package/package.json
npm ERR! parse error SyntaxError: Unexpected token }
npm ERR! parse error at Object.parse (native)
npm ERR! parse error at /usr/local/lib/node/.npm/npm/0.3.7/package/lib/utils/read-json.js:71:17
npm ERR! parse error at P (/usr/local/lib/node/.npm/npm/0.3.7/package/lib/utils/read-json.js:62:40)
class Suite
constructor: (options={
foo: '...'
bar: '...'}) ->
if @constructor.instance
throw new Error 'Please use Suite.getInstance()'
else
@constructor.instance = this
((exports) ->
# ...
)(if exports? then exports else @mymodule = {})
# vs
((exports) ->
# ...
((exports) ->
# ...
)(if exports? then exports else @mymodule = {})
http = require 'http'
server = http.createServer (req, res) ->
res.writeHead 200, {'Content-Type': 'text/plain'}
res.end 'Hello World\n'
server.listen 8124, "127.0.0.1", () ->
console.log 'Server running at http://127.0.0.1:8124/'

Installing NodeJS and NPM

Prereqs (Ubuntu)

sudo apt-get install

  • build-essential
  • libssl-dev
  • git-core
1 if x
2 else if y
3 else if z

-->

if x
  1
else if y

CHCMF[H]: (coord to coord)-mapping format[, with hashes]

  • CCMF: (Closure's format)
  • CCMFH: (Closure's format) + (backward-compatible extras)

CCMF

Let json_encode be a JSON encoder such that no linebreaks occur in its output.