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 fs = require('fs'); | |
String.prototype.endsWith = function (suffix) { | |
return this.indexOf(suffix, this.length - suffix.length) !== -1; | |
}; | |
var dir = process.argv[2]; | |
var postFix = process.argv[3]; | |
fs.readdir(dir, function (err, list) { |
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 filterListModule = require('./filterListModule'); | |
var dir = process.argv[2]; | |
var postFix = process.argv[3]; | |
filterListModule(dir, postFix, function (err, filteredList) { | |
filteredList.forEach(function (fileName) { | |
console.log(fileName); | |
}); | |
}); |
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 http = require('http') | |
var url = process.argv[2] | |
http.get(url, function (resp) { | |
resp.setEncoding('utf8') | |
resp.on("data", console.log) | |
}); |
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 http = require('http') | |
var url = process.argv[2] | |
http.get(url, function (resp) { | |
var respContent = "" | |
resp.setEncoding('utf8') | |
resp.on("data",function (data) { | |
respContent += data |
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') | |
var moment = require("moment") | |
var port = process.argv[2] | |
net.createServer(function (socket) { | |
socket.end(moment().format("YYYY-MM-DD HH:mm") + "\n") | |
}).listen(port) |
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 http = require('http') | |
var fs = require('fs') | |
var port = process.argv[2] | |
var fileName = process.argv[3] | |
http.createServer(function (request, response) { | |
fs.createReadStream(fileName).pipe(response) | |
}).listen(port) |
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 http = require('http') | |
var map = require('through2-map') | |
var port = process.argv[2] | |
http.createServer(function (request, response) { | |
request | |
.pipe(map(function (chunk) { | |
return chunk.toString().toUpperCase() | |
})) |
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 http = require('http') | |
var url = require('url') | |
var port = process.argv[2] | |
http.createServer(function (request, response) { | |
response.writeHead(200, { 'Content-Type': 'application/json' }) | |
var reqContent = url.parse(request.url, 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 express = require('express') | |
var app = express() | |
app.set('view engine', 'jade') | |
app.set('views', process.argv[3]) | |
app.get('/home', function (req, res) { | |
res.render('index', {date: new Date().toDateString()}) | |
}) | |
app.listen(process.argv[2]) |
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 express = require('express') | |
var app = express() | |
app.use(express.urlencoded()) | |
app.post('/form', function (req, res) { | |
var formDataReversed = req.body.str.split('').reverse().join('') | |
res.end(formDataReversed) | |
}) | |
app.listen(process.argv[2]) |
OlderNewer