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
| 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() |
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
| (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"); | |
| } |
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
| # 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 | |
| # ----- |
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
| 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; |
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
| global.config = | |
| foo: 'bar' |
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
| nodemodules@mercury:~/build/node-v0.3.8$ coffee | |
| coffee> names = ['John', 'Sally'] | |
| John,Sally | |
| coffee> ("Hi #{name}" for name in names) | |
| Hi Sally | |
| coffee> |
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
| 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) |
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
| pth = path.resolve location | |
| fh = fs.createWriteStream(pth) | |
| request | |
| method: 'GET' | |
| uri: uri | |
| encoding: 'binary' | |
| .pipe(fh) |
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
| class Foo | |
| CONSTANT: 1 | |
| bar: -> | |
| @CONSTANT |
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
| L1 = [1, 2, 3, 4, 5] | |
| L2 = [6, 7, 8, 9, 10] | |
| ([x, y] for x of L1 for y of L2)join ' ' |