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 fs = require('fs'); | |
var content = fs.readFile(process.argv[2],function(err,data){ | |
if(err){ | |
console.log('error'); | |
} | |
var lines=data.toString().split('\n'); | |
console.log(lines.length-1); | |
}); |
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 fs = require('fs'); | |
var file = fs.readFileSync(process.argv[2]); | |
var arr=file.toString().split('\n'); | |
console.log(arr.length - 1); |
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
console.log("HELLO WORLD"); |
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 sum=0; | |
var arr=process.argv; | |
for (var i=2; i<arr.length; i++){ | |
sum=sum+Number(arr[i]); | |
} | |
console.log(sum); |
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 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 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 mod = require('./module1'); | |
mod(process.argv[2], process.argv[3], function (err, listf) { | |
if (err) { | |
console.log('Error!') | |
} else { | |
for (var i = 0; i < listf.length; i++) { | |
console.log(listf[i]); | |
} | |
} |
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') | |
http.get(process.argv[2], function (response) { | |
response.setEncoding('utf8') | |
response.on('data', console.log) | |
response.on('error', console.error) | |
}) |
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 bl = require('bl'); | |
var http = require('http'); | |
var url = process.argv[2]; | |
http.get(url, function(res) | |
{ | |
res.setEncoding("utf8"); | |
res.pipe(bl(function (err,data) | |
{ | |
if(err) |
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
/* | |
The most common way to track users in Google Analytics is by using cookies. But sometimes | |
there are platform and security limitations that will not allow cookies to be set or | |
stored for multiple sessions. The following code uses the localStorage property (available | |
now in most browsers) to provide an alternate way to the cookie-based solution. The code | |
is heavily commented to help even the most casual users understand the overall workings | |
of the code. Feel free to ignore this part if you know what you are doing. | |
This work is based on a Google example: | |
https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-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
//Note that this is an INEFFICIENT way to solve the problem | |
function noob_way() { | |
// get test data from a test data utility | |
var cars=get_data_set("basic"); | |
for (var i in cars){ | |
if(cars[i]["model"]!==undefined) { | |
Logger.log(cars[i]["model"]); // Logger.log() is Google App Script's console.log |
OlderNewer