Skip to content

Instantly share code, notes, and snippets.

@papnkukn
papnkukn / csv2json.js
Last active September 16, 2017 16:13
A simple Node.js script to convert CSV to JSON
//Node.js script to convert CSV to JSON
var fs = require('fs');
//Parameters
var infile = process.argv[2]; //First command line arg
var outfile = process.argv[3] || (infile + ".json"); //Last command line arg or add ".json" extension
//Read CSV file
var content = fs.readFileSync(infile, 'utf8');
@papnkukn
papnkukn / download.js
Last active September 19, 2024 21:24
Backup Gmail / Download all Gmail e-mail messages using REST API and Node.js
const fs = require('fs');
const path = require('path');
const readline = require('readline');
const {google} = require('googleapis');
const SCOPES = ['https://www.googleapis.com/auth/gmail.readonly'];
const TOKEN_PATH = 'token.json';
const OUTPUT_FOLDER = './output';
const METADATA_FILE = 'metadata.json';
@papnkukn
papnkukn / server.js
Created October 2, 2022 07:55
A very simple pastebin clone. Pure Node.js with no external dependencies.
/*** A very simple pastebin clone ***/
const fs = require('fs');
const path = require('path');
const http = require('http');
const host = process.env.NODE_HOST || "0.0.0.0";
const port = process.env.NODE_PORT || 3000;
const datadir = process.env.NODE_DATA_DIR || "data";