/*
The model is something like:
Person: { name: String }
Car: { name: String, driver: {type: Schema.Types.ObjectId, ref: 'Person'} }
*/
// Somewhere we do this…
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 _ = require('lodash') | |
var utils = require('./mongo-utils') | |
var docs = require('./random-fixtures')(50000) | |
var db = utils.connect('mongodb://localhost/test') | |
db | |
.then(utils.collection('articles')) | |
.then(utils.clear) |
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
function wrap (fn, args, thisArg) { | |
return function () { | |
return Promise(function (resolve, reject) { | |
fn.apply(thisArg, (args || []).concat([function (err, res) { | |
if (err) reject(err) | |
else resolve(res) | |
}])) | |
}) | |
} | |
} |
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
"use strict"; | |
/** | |
Save as config/index.js | |
Config files = | |
- config/config.json | |
- config/config.$NODE_ENV.json | |
- config/config.$NODE_ENV.$USER.json | |
**/ |
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
function defer () { | |
var _resolve, _reject; | |
var promise = new Promise(function (resolve, reject) { | |
_resolve = resolve; | |
_reject = reject; | |
}); | |
return { | |
"promise": promise, |
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
console.log(JSON.stringify(pathsToTree([ | |
"a/b", | |
"a/c/d", | |
"e" | |
]), null, " ")); | |
/* | |
{ | |
"e": null, | |
"a": { |
Before (not good):
return <ul>{ paragraphs.map(p => <li>{ p }</li>) }</ul>;
// Each child in an array should have a unique "key" prop. Check the render method of RoomSpace. See http://fb.me/react-warning-keys for more information.
Uglier (not sure better):
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
gnome-terminal --zoom=5 -e ~/bin/tts.sh |
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
function dirTree (filename, cb) { | |
fs.lstat(filename, function (err, stat) { | |
if (err) { | |
return cb(err); | |
} | |
var info = { | |
"path": filename, | |
"name": path.basename(filename) |
OlderNewer