Last active
August 29, 2015 14:01
-
-
Save kopasetik/16458b7f3720bf203079 to your computer and use it in GitHub Desktop.
Learnyounode
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
(function(){ | |
args = process.argv; | |
args.shift(); | |
args.shift(); | |
var total = args.reduce(function(a,b){ | |
return parseInt(a,10) + parseInt(b,10); | |
}); | |
console.log(total); | |
})() |
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
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'); | |
var directory = process.argv[2], | |
extension = process.argv[3]; | |
//console.error(process.argv); | |
fs.readdir(directory, function(err, list) { | |
if (err) { | |
console.error(err); | |
return; | |
} | |
list.filter(function(input){ | |
var reggie = new RegExp( ".*\\." + extension + "$", "g"); | |
return reggie.test(input); | |
}). | |
forEach(function(x){ | |
console.log(x) | |
}); | |
}); |
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'); | |
var path = require('path'); | |
module.exports = function (dir, ext, charlie){ | |
fs.readdir(dir, function(err, list) { | |
if (err) { | |
charlie(err, null); | |
return; | |
} | |
var lisa = list.filter(function(input){ | |
var paddy = path.extname(input); | |
return paddy == ("." + ext); | |
}); | |
charlie(null, lisa); | |
}); | |
}; |
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') | |
var path = require('path') | |
fs.readdir(process.argv[2], function (err, list) { | |
list.forEach(function (file) { | |
if (path.extname(file) === '.' + process.argv[3]) | |
console.log(file) | |
}) | |
}) |
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 file = process.argv[2]; | |
var fs = require('fs'); | |
fs.readFile(file, function(err, data){ | |
if (err) throw err; | |
console.log(data.toString().match(/\n/g).length); | |
}); |
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 file = process.argv[2]; | |
var fs = require('fs'); | |
var doc = fs.readFileSync(file); | |
var x = doc.toString().match(/\n/g).length; | |
console.log(x); |
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 filterFcn = require('./filteredLsModule'); | |
filterFcn(process.argv[2], process.argv[3], function(err, list) { | |
if (err) { | |
console.error("This is the error: " + err); | |
} | |
list.forEach(function(argument) { | |
console.log(argument); | |
}); | |
}); |
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 myTest = require('./moduleTest2'); | |
myTest(); |
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(){ | |
console.log("Hello"); | |
}; |
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
console.log("HELLO WORLD") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment