Skip to content

Instantly share code, notes, and snippets.

View tanepiper's full-sized avatar

Tane Piper tanepiper

View GitHub Profile
module.exports = (settings, db) ->
express = require "express"
app = express.createServer()
app.configure ->
app.set 'views', "views"
app.set "view engine", "jade"
app.use express.logger()
app.use express.bodyDecoder()
(function() {
module.exports = function(settings, database) {
return function(req, res, next) {
var db, id;
if (req.method.toLowerCase() === "get") {
if (req.session && req.session.user) {
return res.redirect('/application');
} else {
return res.render("login");
}
# Swappable Mixins in CoffeeScript
# ================================
# This is experimental. Not tested. It's just a toy, and I'm very new to
# javascript/coffeescript. Be warned.
# Usage
# -----
mixin = module.exports = (o, c, defaults) ->
if defaults
mixin o, defaults
if o and c and typeof c is 'object'
for key, val of c
o[key] = val
return o;
global.config =
foo: 'bar'
nodemodules@mercury:~/build/node-v0.3.8$ coffee
coffee> names = ['John', 'Sally']
John,Sally
coffee> ("Hi #{name}" for name in names)
Hi Sally
coffee>
nodemodules@mercury:~/build/node-v0.3.8$ coffee
coffee> names = ['John', 'Sally']
John,Sally
coffee> ("Hi #{name}" for name in names)
Hi Sally
coffee> names = ['John', 'Sally', 'Tom']
John,Sally,Tom
coffee> ("Hi #{name}" for name in names)
Hi Tom
coffee> x= ("Hi #{name}" for name in names)
pth = path.resolve location
fh = fs.createWriteStream(pth)
request
method: 'GET'
uri: uri
encoding: 'binary'
.pipe(fh)
class Foo
CONSTANT: 1
bar: ->
@CONSTANT
L1 = [1, 2, 3, 4, 5]
L2 = [6, 7, 8, 9, 10]
([x, y] for x of L1 for y of L2)join ' '