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 c = console; | |
console = { | |
log : function() { | |
var args = Array.prototype.slice.apply(arguments); | |
setTimeout(function() { | |
c.log.apply(c, args); | |
}, 5000); | |
} | |
}; |
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
// Start from https://gist.github.com/iwek/7154578#file-csv-to-json-js | |
// and fix the issue with double quoted values | |
function csvTojs(csv) { | |
var lines=csv.split("\n"); | |
var result = []; | |
var headers = lines[0].split(","); | |
for(var i=1; i<lines.length; i++) { | |
var obj = {}; |
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 disk = require('diskusage'); | |
disk.check('/', function(err, info) { | |
function toGB(x) { return (x / (1024 * 1024 * 1024)).toFixed(1); } | |
var percentAvailable = ((info.available / info.total) * 100); | |
if (percentAvailable < 10) { console.log('Warning only ' + toGB(info.available) + 'GB (' + percentAvailable.toFixed(1) + '%) space available!'); } | |
}); |
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
/* switch to admin database and get list of databases */ | |
db = db.getSiblingDB("admin"); | |
dbs = db.runCommand({ "listDatabases": 1 }).databases; | |
/* iterate through each database and get its collections */ | |
dbs.forEach(function(database) { | |
print(database.name); | |
db = db.getSiblingDB(database.name); | |
cols = db.getCollectionNames(); |
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 Mbox = require('node-mbox'); | |
var MailParser = require("mailparser").MailParser; | |
var mbox = new Mbox('inbox.mbox', { /* options */ }); | |
var bouncingEmails = []; | |
mbox.on('message', function(msg) { | |
var mailparser = new MailParser(); | |
mailparser.on("end", function(mail) { |
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
module.exports = function(path, cb) { | |
var xhr = new XMLHttpRequest(); | |
xhr.overrideMimeType("application/json"); | |
xhr.open('GET', path, true); | |
xhr.onreadystatechange = function() { xhr.readyState === 4 && xhr.status === 200 && cb(JSON.parse(xhr.responseText)); }; | |
xhr.send(null); | |
}; |
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
function format(node, level) { | |
var indentBefore = new Array(level++ + 1).join(' '); | |
var indentAfter = new Array(level - 1).join(' '); | |
var textNode; | |
for (var i = 0; i < node.children.length; i++) { | |
textNode = document.createTextNode('\n' + indentBefore); | |
node.insertBefore(textNode, node.children[i]); | |
format(node.children[i], level); | |
if (node.lastElementChild === node.children[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
'use strict'; | |
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; | |
var localtunnel = require('localtunnel'); | |
var request = require('request'); | |
var qs = require('querystring'); | |
var url = require('url'); | |
var http = require('http'); |
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
'use strict'; | |
const steem = require('steem'); | |
/* to be filled up */ | |
const selfName = ''; | |
const postingWif = ''; | |
const eol = '\n'; |
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
'use strict'; | |
/* to be filled up */ | |
const selfName = 'jonmaim'; | |
const postingWif = 'xxx'; | |
const steem = require('steem'); | |
const timeout = (ms) => new Promise(resolve => setTimeout(resolve, ms)); |