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 = class FooController | |
| get: ({params: {foo}}, res) -> | |
| get("http://localhost:9292/api/#{foo}.json") | |
| .then (response) -> | |
| res.status response.status | |
| if response.status == 200 | |
| then res.end JSON.stringify transformResponse response.body | |
| else res.end response.text |
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
| // james-coffee/index.js | |
| var james = require('james'), | |
| coffee = require('coffee-script'); | |
| coffee.createStream = function() { | |
| return james.createTransformation(function(content, callback) { | |
| // Process the file content and call the callback with the result. | |
| try { | |
| res = coffee.compile(content); |
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 Helpers | |
| def select2(scope, opts) | |
| scope.find('.select2-choice').click | |
| if opts.has_key? :type_in | |
| input = find '.select2-drop-active:not(.select2-offscreen) .select2-search .select2-input' | |
| input.set opts[:type_in] | |
| input.trigger('keyup-change') | |
| end |
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
| Q = require 'q' | |
| _ = require 'underscore' | |
| photos = [1..100] | |
| partition = (n, coll) -> | |
| _.values(_.groupBy(coll, (x, i) -> Math.floor i/n)) | |
| scaleImage = (img, i) -> | |
| Q.delay(200).then -> console.log "processed image #{i}" |
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' | |
| path = require 'path' | |
| http = require 'http' | |
| logger = require 'winston' | |
| app = express() | |
| logger.setLevels logger.config.syslog.levels | |
| logger.remove logger.transports.Console | |
| logger.add logger.transports.Console, |
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 phantom = require('james-phantomjs'), | |
| mocha = require('james-mocha'), | |
| dotReporter = require('james-dot-reporter'); | |
| mocha(james.list('test/*Helper.js', 'test/*Spec.js')) | |
| .transform(phantom) | |
| .transform(dotReporter); |
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
| through = require('through'); | |
| module.exports = function (file) { | |
| var tr = through(null, function () { | |
| this.queue('}).call(module.exports)'); this.queue(null) }); tr.pause(); | |
| tr.queue('(function(){'); process.nextTick(tr.resume.bind(tr)); return tr; | |
| } |
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 assert = require('assert'), | |
| StringStream = require('../index'), | |
| data = "Hello World!", | |
| src = new StringStream(data), | |
| dest = new StringStream(); | |
| src.pipe(dest); | |
| dest.on('finish', function() { | |
| assert.equal(src.data, ''); |
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
| /* | |
| <div class="template"> | |
| <div class="todo"></div> | |
| <div> | |
| */ | |
| data = [ |
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
| exports.hello = function(name) { | |
| console.log("Hello, " + name); | |
| } |