-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
298d8db
commit 8ee5fa9
Showing
128 changed files
with
9,674 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module.exports = function(url, callback){ | ||
|
||
var http = require('http'); | ||
|
||
var allData = ""; | ||
|
||
http.get(url, function(response){ | ||
|
||
response.setEncoding('utf8'); | ||
response.on('data', function(data){ | ||
allData = allData + data; | ||
}); | ||
|
||
response.on("end", function(){ | ||
callback(null, allData); | ||
}); | ||
|
||
response.on("error", function(err){ | ||
callback(err); | ||
}); | ||
}); | ||
|
||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
var collect = require('./CollectHttpMod'); | ||
|
||
var allData = []; | ||
var responseCount = 0; | ||
|
||
var onComplete = function(){ | ||
if (responseCount === 3){ | ||
for (var data in allData){ | ||
//console.log("NEXT"); | ||
console.log(allData[data]); | ||
} | ||
} | ||
}; | ||
|
||
collect(process.argv[2], function(err, data){ | ||
if(err){ | ||
console.log("Error Server 1"); | ||
}{ | ||
allData[0] = data; | ||
responseCount ++; | ||
onComplete(); | ||
} | ||
|
||
}); | ||
|
||
collect(process.argv[3], function(err, data){ | ||
if(err){ | ||
console.log("Error Server 2"); | ||
}{ | ||
allData[1] = data; | ||
responseCount ++; | ||
onComplete(); | ||
} | ||
|
||
}); | ||
|
||
collect(process.argv[4], function(err, data){ | ||
if(err){ | ||
console.log("Error Server 3"); | ||
}{ | ||
allData[2] = data; | ||
responseCount ++; | ||
onComplete(); | ||
} | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
var vars = process.argv.slice(2); | ||
|
||
//console.log(process.argv); | ||
var result = 0; | ||
for ( var arg in vars ){ | ||
|
||
var number = Number(vars[arg]); | ||
if (number){ | ||
result = result + number; | ||
//console.log(result); | ||
|
||
} | ||
} | ||
|
||
console.log(result); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var fs = require('fs'); | ||
|
||
var path = process.argv[2]; | ||
|
||
var buf = fs.readFileSync(path); | ||
|
||
var content = buf.toString(); | ||
var lines = content.split('\n'); | ||
|
||
console.log(lines.length -1); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var fs = require('fs'); | ||
|
||
var path = process.argv[2]; | ||
|
||
var buf = fs.readFile(path, 'utf8', function (err, content) { | ||
if (!err){ | ||
var lines = content.split('\n'); | ||
console.log(lines.length -1); | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var http = require('http'); | ||
|
||
var server = http.createServer(function(req, res) { | ||
res.writeHead(200); | ||
res.end('Hello Http'); | ||
|
||
}); | ||
server.listen(8080); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log("HELLO WORLD"); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var http = require('http'); | ||
|
||
var allData = ""; | ||
|
||
http.get(process.argv[2], function(response){ | ||
|
||
response.setEncoding('utf8'); | ||
response.on('data', function(data){ | ||
allData = allData + data; | ||
}); | ||
|
||
response.on("end", function(){ | ||
console.log(allData.length); | ||
console.log(allData); | ||
}); | ||
|
||
response.on("error", function(err){ | ||
console.log("Error " + err); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var http = require('http'); | ||
var fs = require('fs'); | ||
|
||
var server = http.createServer(function (req, res) { | ||
var fStream = fs.createReadStream(process.argv[3]); | ||
fStream.pipe(res); | ||
}); | ||
server.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var http = require('http'); | ||
|
||
http.get(process.argv[2], function(response){ | ||
|
||
response.setEncoding('utf8'); | ||
response.on('data', function(data){ | ||
console.log(data); | ||
}); | ||
|
||
response.on("error", function(err){ | ||
console.log("Error " + err); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var http = require('http'); | ||
var url = require('url'); | ||
var parsedUrl; | ||
|
||
var server = http.createServer(function (req, res) { | ||
parsedUrl = url.parse(req.url, true); | ||
// console.log(parsedUrl); | ||
var date = new Date(parsedUrl.query.iso); | ||
res.writeHead(200, {'Content-Type': 'application/json'}); | ||
switch(parsedUrl.pathname){ | ||
case '/api/parsetime': | ||
res.end(JSON.stringify({ | ||
hour : date.getHours(), | ||
minute : date.getMinutes(), | ||
second : date.getSeconds() | ||
})); | ||
break; | ||
|
||
case '/api/unixtime': | ||
res.end(JSON.stringify({ | ||
unixtime : date.getTime() | ||
})); | ||
break; | ||
} | ||
}); | ||
server.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var http = require('http'); | ||
var map = require('through2-map'); | ||
|
||
var server = http.createServer(function (req, res) { | ||
if(req.method === 'POST'){ | ||
req.pipe(map(function(chunk){ | ||
return chunk.toString().toUpperCase(); | ||
})).pipe(res); | ||
} | ||
}); | ||
server.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var fs = require('fs'); | ||
|
||
var filter = '.' + process.argv[3]; | ||
|
||
//console.log(filter); | ||
fs.readdir(process.argv[2], function(err, list){ | ||
for (var item in list){ | ||
if (String(list[item]).indexOf(filter) > -1){ | ||
console.log(list[item]); | ||
} | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module.exports = function(path, filter, callback){ | ||
var fs = require('fs'); | ||
|
||
var matchingFiles = []; | ||
//console.log(filter); | ||
fs.readdir(path, function(err, list){ | ||
if (err) | ||
return callback(err); | ||
for (var item in list){ | ||
if (String(list[item]).indexOf('.' + filter) > -1){ | ||
matchingFiles.push(list[item]); | ||
} | ||
} | ||
callback(null,matchingFiles); | ||
}); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var myMod = require("./listDirModule"); | ||
|
||
|
||
myMod(process.argv[2], process.argv[3], function(err, files){ | ||
if(err){ | ||
console.log("Error"); | ||
}{ | ||
for ( var file in files){ | ||
console.log(files[file]); | ||
} | ||
} | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.