Skip to content

Instantly share code, notes, and snippets.

@papnkukn
papnkukn / server.js
Created October 2, 2022 07:55
A very simple pastebin clone. Pure Node.js with no external dependencies.
View server.js
/*** 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";
@papnkukn
papnkukn / download.js
Last active April 27, 2023 11:01
Backup Gmail / Download all Gmail e-mail messages using REST API and Node.js
View download.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 / csv2json.js
Last active September 16, 2017 16:13
A simple Node.js script to convert CSV to JSON
View csv2json.js
//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');