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 args = process.argv.slice(2); | |
| var httpGet = require('./http_get'); | |
| httpGet(args[0], function(err, data) { | |
| if (err) throw err; | |
| console.log(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 args = process.argv.slice(2); | |
| var httpPipe = require('./http_pipe'); | |
| httpPipe(args[0], function(err, data) { | |
| if (err) throw err; | |
| console.log(data.length); | |
| console.log(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 http = require('http'); | |
| var bl = require('bl'); | |
| module.exports = function(url, callback) { | |
| var result = ''; | |
| http.get(url, function(res) { | |
| res.setEncoding('utf8'); | |
| res.pipe(bl(function(err, data) { | |
| result += data.toString(); |
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 args = process.argv.slice(2); | |
| var httpPipe = require('./http_pipe'); | |
| var queue = [], cur; | |
| var httpGet = function(url) { | |
| function callback(err, data) { | |
| if (err) throw err; | |
| console.log(data); | |
| if (queue.length) { |
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 args = process.argv.slice(2); | |
| var net = require('net'); | |
| var strftime = require('strftime'); | |
| net.createServer(function(socket) { | |
| socket.end(strftime('%F %R') + '\n'); | |
| }).listen(+args[0]); |
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 args = process.argv.slice(2); | |
| var http = require('http'); | |
| var map = require('through2-map'); | |
| var server = http.createServer(function(req, res) { | |
| req.pipe(map(function(chunk) { | |
| return chunk.toString().toUpperCase(); | |
| })).pipe(res); | |
| //console.log(req.pipe); | |
| }); |
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 args = process.argv.slice(2); | |
| var http = require('http'); | |
| var url = require('url'); | |
| var server = http.createServer(function(req, res) { | |
| if (req.method != 'GET') { | |
| res.end("Alows to use only GET HTTP request"); | |
| return; | |
| } | |
| var parsedUrl = url.parse(req.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 args = process.argv.slice(2); | |
| var http = require('http'); | |
| var url = require('url'); | |
| var server = http.createServer(function(req, res) { | |
| if (req.method != 'GET') { | |
| res.end("Allows to use only GET HTTP request"); | |
| return; | |
| } | |
| var parsedUrl = url.parse(req.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
| function checkUsersValid(goodUsers) { | |
| return function(submittedUsers) { | |
| return submittedUsers.every(function(el) { | |
| var cur_id = el.id; | |
| return goodUsers.some(function(el) { | |
| return el.id === cur_id; | |
| }); | |
| }); | |
| }; | |
| } |
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 util = require('util'); | |
| function countWords(inputWords) { | |
| return inputWords.reduce(function (prev, cur) { | |
| if (!util.isObject(prev)) { | |
| var obj = {}; | |
| obj[prev] = 1; | |
| obj[cur] = 1; | |
| return obj; | |
| } |