Skip to content

Instantly share code, notes, and snippets.

var Nothing = {Nothing: true}
function MaybeGenerator() {
var g = arguments[arguments.length - 1]
// list of functions that test for any "Nothing" values
var maybes = [].slice.call(arguments,0,arguments.length - 1)
return function(value) {
var generator = g.apply(null,[].slice.call(arguments,1))
var result
# Meet Chef
## Recap : Terminology
+ node
A host where the Chef client will run (db,web,worker)
+ chef client
The command line program of that configures servers
+ chef server
A database-backed web server that stores searchable information about your production servers.

Debugging & Profiling Node.js

This is a maintained listing of all the different ways to debug and profile Node.js applications. If there is something missing or an improvement, post a comment! :)

Interactive Stack Traces with traceGL - Shareware

  1. Guide here
@Rafe
Rafe / index.js
Created April 23, 2013 04:44
Solving binary search problem from http://code-warrior.herokuapp.com.
module.exports = function(array, value) {
var left = 0;
var right = array.length - 1;
var tracker = [];
while (left <= right) {
var mid = Math.floor((left + right) / 2);
tracker.push(array[mid]);
if (array[mid] == value) return tracker ;
if (array[mid] < value) {
left = mid + 1;
@Rafe
Rafe / index.js
Created April 13, 2013 00:28
Solving tree traversal problem from http://code-warrior.herokuapp.com.
var preorder = exports.preorder = function (head, tracker) {
if (head == null) return;
tracker.push(head.data);
preorder(head.left, tracker);
preorder(head.right, tracker);
}
var inorder = exports.inorder = function (head, tracker) {
if (head == null) return;
inorder(head.left, tracker);
@Rafe
Rafe / index.js
Created April 11, 2013 23:43
Solving fabonacci problem from http://code-warrior.herokuapp.com.
var cache = {};
var fabonacci = module.exports = function(n) {
if (n == 0) return 0;
if (n == 1) return 1;
if (!cache[n]) {
cache[n] = fabonacci(n - 1) + fabonacci(n - 2);
}
return cache[n];
}
@Rafe
Rafe / index.js
Created April 11, 2013 22:43
Solving count 2s problem from http://code-warrior.herokuapp.com.
var count2 = function(n) {
if (n == 0) return 0;
var power = 1;
while (10 * power < n) power *= 10;
var first = Math.floor(n / power);
var remain = n % power;
var n2s = 0;
if (first > 2) {
@Rafe
Rafe / index.js
Created April 2, 2013 18:29
Solving Frequency of occurrences problem from http://code-warrior.herokuapp.com.
module.exports = function (book, word) {
var words = book.replace(/.,/, ' ').toLowerCase().split(' ');
var dict = {}
words.forEach(function(w) {
if (dict[w]) {
dict[w] += 1;
} else {
dict[w] = 1;
};
});
@Rafe
Rafe / index.js
Created April 2, 2013 16:25
Solving continous sequence sum problem from http://code-warrior.herokuapp.com.
module.exports = function (seq) {
var maxsum = -1000000000;
var sum = 0;
for (var i = 0; i < seq.length; i++) {
sum += seq[i];
if(sum > maxsum) {
maxsum = sum;
}
if (sum < 0) {
sum = 0;
@Rafe
Rafe / index.js
Created April 2, 2013 16:02
Solving continous sequence sum problem from http://code-warrior.herokuapp.com.
module.exports = function (seq) {
var maxsum = 0;
for (var i = 0; i < seq.length; i++) {
var sum = 0;
for (var j = i; j < seq.length; j++) {
sum += seq[j];
if(sum > maxsum) {
maxsum = sum;
}
};