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 httprequest = require('request'); | |
var page = 1; | |
(function repeat() { | |
var req = httprequest("http://www.google.com", function (error, response, body) { | |
console.log(response.statusCode); | |
if (page < 2) { | |
page += 1; | |
repeat(); | |
} else { | |
console.log('done'); |
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
module.exports = function (port, path) { | |
"use strict"; | |
var http = require('http'), | |
express = require('express'), | |
app = express(), | |
server = http.createServer(app), | |
path = path || __dirname, | |
port = port || 8555; | |
app.use(express.static(path)); |
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 net = require('net'), | |
bro = '....Cool story bro.\r\n', | |
Stream = require('stream'), | |
stream = new Stream, | |
server = net.createServer(function (socket) { | |
socket.setEncoding('utf8'); | |
socket.pipe(stream).pipe(socket); | |
}); | |
stream.readable = true; |
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 httpProxy = require('http-proxy'), | |
httpOptions = { | |
router: { | |
'someservername' : '127.0.0.1:3001', | |
'otherservername' : '127.0.0.1:3002', | |
'/*' : '127.0.0.1:3000' | |
} | |
}, | |
httpProxyServer = httpProxy.createServer(httpOptions); |
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 https = require('https'); | |
https.get('https://registry.npmjs.org/', function responseHandler(res) { | |
var response = ''; | |
res.on('data', function dataCallback(chunk) { | |
response += chunk; | |
}); | |
res.on('end', function endCallback() { | |
var json = JSON.parse(response); | |
console.log(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
var server = require('http').createServer(handler).listen(function () { console.log(this.address()); }); | |
var fs = require('fs'); | |
var levelup = require('level'); | |
var subLevel = require('level-sublevel'); | |
var dbPath = './test'; | |
if (!fs.existsSync(dbPath)) { | |
fs.mkdirSync(dbPath); | |
} | |
var db = subLevel(levelup(dbPath)); |
NewerOlder