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
#!/usr/bin/env bash | |
# :vim setf bash | |
# Constants: | |
tunPort=9876; | |
screenSessId="teleport_$$" | |
# Define handy default values: | |
allHostNames=$(hostname -A); | |
srcFQDN=${allHostNames%% *} |
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
// USAGE: objectMap(<object>, <callback>) | |
// <object>: Any regular JavaScript object. | |
// <callback>: function(<current_value>, <current_key>, <original_object>) {...} | |
// EXAMPLE: | |
// objectMap({a: null, b: "23"}, Number) //-> { a: 0, b: 23 } | |
function objectMap(obj, cbk) { | |
return Object.fromEntries( | |
Object.entries(obj).map( | |
([key, value])=>[key, cbk(value, key, 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
export class smallCache extends Array { | |
constructor(maxlength = 10) { | |
super(); | |
Object.defineProperty(this, "maxlength", { | |
value: maxlength, | |
enumerable: false, |
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 aside(...args) { | |
// Usage examples: | |
// --------------- | |
// console.log(aside(var1, var2)); | |
// console.log(aside({var1, var2, someValue: 23})); | |
// console.log(aside.bind("My title")(var1, var2)); | |
// console.log( | |
// aside.bind({ | |
// title: "My title", | |
// separator: "#", |
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
// sampleModule/index.js | |
// ===================== | |
// EDAM - Event Driven Async Module | |
// (Example / Skeleton) | |
"use strict"; | |
module.exports = (async ()=>{ | |
// Module-level definitions: | |
const module_preferences = { | |
p1: 10, |
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
// wildcards(pattern [, modifiers]) | |
// ================================ | |
// | |
// Transform search patterns with wildcards ('*' and '?') | |
// to suitable regular expresions. | |
// | |
// CAUTION: Pre-wrap with '*' (if needed). | |
// | |
// @@ Examples: @@ // | |
// @@ --------- @@ // |
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
Translate well known filesystem-like wilcards ('?' for single character and '*' for 0 or more) to: | |
a) Suitable SQL pattern (with '_' and '%' instead) for 'like' and 'ilike' comparsion. | |
b) Suitable regular expression. | |
In both cases whithout breaking anything. That is, exitent meaningful ('%', and '_' for DB | |
and '.', '+', '[', etc... for regular expressions) should be properly escaped. | |
Also: |
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
// Promise cancellation utility | |
// Inspired on this @getify tweet: | |
// https://twitter.com/getify/status/1171820071582339072 | |
// (Deferrable version) | |
// ----- IMPLEMENTATION: ----- | |
function cancellator() { | |
let cancelTimowut = null; | |
let cancelMessage = "Cancelled"; | |
const stoppers = []; |
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
// Unless it could become ECMASCRIPT proposal best practice | |
// would be to use regular function in order to avoid polluting | |
// [function]'s prototype | |
// Twitter: https://twitter.com/bitifet/status/1166745132651220992?s=20 | |
const softBind = (function() { | |
const master = Symbol(); | |
return function softBind(self, ...args) { | |
const fn0 = self[master] || self; | |
const fn = fn0.bind(...args) | |
fn[master] = fn0; |
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
[B9B80A21DF98BE68DB4033CF3D4D2246B2AF9078989B9AB5260C1C5F349F5BE338DBA0453B87F1C5F2D66B6C1526EC2771317B2DAFB1E22DD0A5A7C689DB6BFBC5745A5569054495288B1B91894C73DDBDAB97F25C862DF282DBF46559AC91165E47A660BB98BAAA6E717724BE210B78C45E3AC83F152D4424965057093B2F2FA1B17257E1DB20F6CE30141F38880B42520F6107C61CDA31815B6E6293B74FDDFC0C9D7159B098FA4F5694F697E1FC6EE92284CA6EE2474F93B32E2608195EAAA573295004DC499276FDC698C2FFDE49543562F3BA5931479F37E9994C0A299FEEDF26247AE0E05890AEE439423633D151CEA28FDEB352BD46AF9F96BB7E18FD99F98CB964C154BE60232C7CFF32B7] |
NewerOlder