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
const sortBy = (...k) => (a,b) => ((k)=> (null==k || a[k]===b[k]) ? 0 : a[k]<=b[k] ? -1 : 1 )(k.find(_k=>a[_k]!==b[_k])); |
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
// like lodash _.get() but key lookup is case-insensitive | |
const iget = (value, prop, defaultValue) => { | |
if (_.isPlainObject(value)) { | |
if (_.isString(prop) && prop !== '') { | |
return iget(value, prop.split('.'), defaultValue); | |
} else if (_.isArray(prop) && prop.length) { | |
const key = _.toLower(prop.shift()), | |
val = Object.keys(value).reduce((a, k) => { | |
if (a !== undefined) { | |
return a; |
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
'use strict'; | |
(exports => { | |
// console.clear(); | |
// | |
// let SAMPLE = ``+ | |
// `SELECT\n`+ | |
// ` Instance.Instance.Id AS Name,\n`+ | |
// ` Instance.Instance.PrivateIpAddress AS "IP Address",\n`+ | |
// ` Instance.Instance.LaunchTime AS Created,\n`+ |
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
/** | |
* Sort a list of hexadecimal strings | |
* by the most unique bytes per line (ie. most entropy). | |
* Useful when searching a list for RNG values, such as cryptographic keys. | |
*/ | |
const fs = require('fs'); | |
const [, , file] = process.argv; | |
const content = fs.readFileSync(file); | |
const lines = content.toString().split(/\n/g); |
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
/* | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
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
const vm = require('vm'); | |
const fp = require('lodash/fp'); | |
const _ = require('lodash'); | |
/** | |
* Successfully mimics jq C implementation in pure Node.JS | |
* by utilizing the Functional Programming (FP) version of Lodash library, which is | |
* critical for jq-like syntax. | |
* | |
* Documentation: https://github.com/lodash/lodash/wiki/FP-Guide |
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
const { Utils } = require('../../../../shared/public/components/utils'); | |
const SharedCache = require('../../../../shared/models/sharedCache'); | |
require('../../../../shared/public/components/flatten'); | |
const uuidv4 = require('uuid/v4'); | |
const makeId = prefix => (prefix||'') + uuidv4().replace(/-/g,''); | |
const sgql = require('../../../../shared/models/sgql'); | |
const _ = require('lodash'); | |
const MODELS = ['User']; |
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
(async () => { | |
const net = require('net'); | |
const dns = require('dns'); | |
const fs = require('fs'); | |
const [,,host,portmin,portmax] = process.argv; | |
let a = Date.now(); | |
const ipv4 = await new Promise((ok,fail) => |
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
// The following is useful when building a | |
// streaming cartesian product (ie. cross join) | |
// e.g., Imagine walking a two-dimensional matrix | |
// having one [column] dimension given and fixed at initialization, | |
// and one dimension of varying, perhaps infinite, lengths [determined by each row]. | |
// A set of nested for...loop would normally accomplish this, | |
// if it weren't for the number of loop statements required varying by invocation. | |
const size = 3; // matrix size variable | |
const len = [3,2,3]; // the length of each list in the matrix (notice they can vary) |
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
Utils.iteratorLoop = () => { | |
const buf = []; | |
let next, done = false; | |
const push = e => { | |
buf.push(e); | |
if (null != next) next(); | |
}; | |
const loop = async function* () { | |
while (true) { | |
yield* buf.splice(0); |