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 names = ['jon', 'jane', 'jack']; | |
// something we want to do with each item in array | |
var log = function(a) { | |
console.log(a); | |
} | |
// using for loop | |
for (var i = 0; i < names.length; i++) { | |
log(names[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
var http = require('http'); | |
var fs = require('fs'); | |
var url = require('url'); | |
var streamMap = require('through2-map'); | |
var port = process.argv[2]; | |
var path = process.argv[3]; | |
var server = http.createServer(function(request, response) { | |
var get = url.parse(request.url, true); |
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 http = require('http'); | |
var fs = require('fs'); | |
var url = require('url'); | |
var streamMap = require('through2-map'); | |
var port = process.argv[2]; | |
var path = process.argv[3]; | |
var server = http.createServer(function(request, response) { | |
var get = url.parse(request.url, true); |
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 http = require('http'); | |
var bl = require('bl'); | |
// file path is from enviroment variable passed in through CLI | |
var urls = process.argv.slice(2); | |
var results = []; | |
var returned = 0; | |
function httpGet(index) { |
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 an idiomatic example of a Node async call with callbacks that | |
// handle both returned data and error | |
/***********This is the module defined for later use */ | |
var fs = require('fs'); | |
module.exports = function(file, ext, callback) { | |
fs.readdir(file, function(err, data) { | |
// if readdir returns error, call callback with error early |
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 http = require('http'); | |
var bl = require('bl'); | |
// file path is from enviroment variable passed in through CLI | |
var url = process.argv[2]; | |
var consolidated = ''; | |
var callback = function(data) { | |
consolidated += 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
var quickSort = function (arr) { | |
if (arr.length === 0) { | |
return []; | |
} | |
var left = []; | |
var right = []; | |
var pivot = arr[arr.length - 1]; // use right most value as pivot | |
_.each(arr.slice(0, arr.length - 1), function (each) { |
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
// implementation of quicksort | |
var quickSort = function (arr) { | |
if (arr.length === 0) { | |
return []; | |
} | |
var left = []; | |
var right = []; | |
var pivot = arr[arr.length - 1]; // use right most value as pivot |
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 gulp = require('gulp'); | |
var browserSync = require('browser-sync') | |
.create(); | |
//var sass = require('gulp-sass'); | |
// Static Server + watching scss/html files | |
gulp.task('serve', function () { | |
browserSync.init({ | |
server: "./" |
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 each(collection, callback) { | |
if (Array.isArray(collection)) { | |
for (var i = 0; i < collection.length; i++) { | |
callback(collection[i]); | |
} | |
} else { | |
for (var j in collection) { | |
callback(collection[j]); | |
} | |
} |