This file contains 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
// /students collection | |
// grades automatic property | |
var student = this | |
, query = { | |
courseId: { | |
$in: student.courses | |
} | |
}; | |
dpd.assignments.average('grade', query, function (avgGrade) { |
This file contains 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
// based on an example by @mikeal | |
var http = require('http') | |
, domain = require('domain') | |
; | |
module.exports = function (handler) { | |
var server = http.createServer(function (req, resp) { | |
var d = domain.create() | |
This file contains 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
// the way you want to do it | |
var files = []; | |
function recurse(dir) { | |
dir.forEach(function (f) { | |
if(stat(f).isFile()) { | |
files.push(f); | |
} else { | |
recurse(fs.readdir(dir)); | |
} |
This file contains 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
/** | |
* First `sn install node-markdown shelljs` | |
* Then `sn markdown-example.js` | |
*/ | |
var md = require('node-markdown').Markdown | |
require('shelljs/global'); | |
/** | |
* Output the sample file as html |
This file contains 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
ast |
This file contains 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
/** | |
* Dependencies | |
*/ | |
var request = require('request'); | |
var loopback = require('loopback'); | |
var app = loopback(); | |
var memoryDataSource = loopback.memory(); | |
var HEADER_NAME = 'x-access-token'; // subject to change |
This file contains 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 adapters = { | |
redis: RedisJobQueue, | |
foo: FooJobQueue, | |
bar: BarJobQueue | |
}; | |
function JobQueueConnector(settings) { | |
this.DataAccessObject = adapters[settings.type]; | |
} |
This file contains 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
// ... imagine backbone boilerplate here... pointing to localhost:3000 | |
var Product = Backbone.Model.extend({ | |
url: '/products' | |
}); | |
/* would be nice if I could just include this here... | |
Product.validatesLengthOf('name', { | |
min: 3, |
This file contains 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
app.controller('RestaurantsController', | |
function RestaurantsController(Restaurant) { | |
$scope.restaurants = Restaurant.query(filterAndSortRestaurants); | |
}); |