- 4 space soft tab
- Always use braces for conditionals/loops
- Opening brace follows conditional/loop closing paren,
else
is on same line - No leading comma
- Always trailing comma (for array and object literals)
gulp
var
declarations must be made before anything else within a given scopevar varFunction = function () {}
<- space between paren and brace
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 arr = new Array(100000); | |
for (var x = 0; x < arr.length; x++) { | |
arr[x] = 1; | |
} | |
console.time("for"); | |
for (var x = 0; x < arr.length; x++) { | |
console.error(arr[x]); | |
} | |
console.timeEnd("for"); |
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 express = require("express"), | |
nonAuthRouter = express.Router(), | |
authRouter = express.Router(), | |
app = express(); | |
authRouter.use(function (req, res, next) { | |
console.log("This is a routers"); | |
next(); | |
}); |
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
reader.pipe(through(function (line) { | |
console.log(line.toString()); | |
this.push(line); | |
})).pipe(outputFile); | |
outputFile.on("close", function (err) { | |
done(err, tmpFile); | |
}); |
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
# | |
# This is the main Apache HTTP server configuration file. It contains the | |
# configuration directives that give the server its instructions. | |
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information. | |
# In particular, see | |
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html> | |
# for a discussion of each configuration directive. | |
# | |
# Do NOT simply read the instructions in here without understanding | |
# what they do. They're here only as hints or reminders. If you are unsure |
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 lorem = require('lorem-ipsum'), | |
exercise = require('workshopper-exercise')(), | |
filecheck = require('workshopper-exercise/filecheck'), | |
execute = require('workshopper-exercise/execute'), | |
comparestdout = require('workshopper-exercise/comparestdout'), | |
path = require("path"), | |
os = require("os"), | |
fs = require("fs"), | |
assert = require("assert"), | |
tmpFile = path.join(os.tmpDir(), "_generators-adventure_" + process.pid + ".txt"); |
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
async.parallel(userId.map(function (individualUserId) { | |
return createMindMessageQuery(individualUserId); | |
}, finalizeQueries); | |
function createMindMessageQuery(userId) { | |
return function (cb) { | |
MindMessage.find({userId: userId, "body.type": "pill_reminder"}, function (err, doc) { | |
if (err) { | |
cb(err) | |
} |
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
// Functional serialized asynchronous recursion | |
(function serialRandomTimeout(x) { | |
if (x.value) { | |
setTimeout(function () { | |
console.log(x.value); | |
serialRandomTimeout(x.next) | |
}, Math.random() * 1000); | |
} | |
})([1,2,3].reduceRight(function (prev, next) { | |
prev.next = JSON.parse(JSON.stringify(prev)); |
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
// Pipe Couch query for consumption by client | |
db.get(document) | |
.pipe(JSONStream(["rows", true, "value"], function (row) { | |
row.special_property = createSpecialProperty(row); | |
return row; | |
}) | |
.pipe(JSONStream.stringify()) | |
.pipe(response); |
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 overloaded_function() { | |
if (1 === arguments.length) { | |
if (Array.isArray(arguments[0])) { | |
multi_function.apply(undefined, [].slice.call(arguments[0])); | |
} | |
else { | |
single_function(arguments[0]); | |
} | |
} | |
else { |