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
const proxify = object => | |
!['function', 'object'].includes(typeof object) | |
? object | |
: new Proxy(object, { | |
/* A trap for a function call */ | |
apply(target, thisArg, args) { | |
console.log('--- apply() ---'); | |
console.dir(object); | |
console.log('target:'); |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
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 |
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
/** | |
* Convert DateTime to timestamp | |
* @param {Number} y Full year | |
* @param {Number} M Month (1..12) | |
* @param {Number} d Date (1..31) | |
* @param {Number} h Hour (0..23) | |
* @param {Number} m Minute (0..59) | |
* @param {Number} s Second (0..59) | |
* @param {Number} l Millisecond (0..999) | |
* @oaram {Number} z Time zone |
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 at(obj, path, val = undefined) { | |
// If path is an Array, | |
if (Array.isArray(path)) { | |
// it returns the mapped array for each result of the path | |
return path.map((path) => at(obj, path, val)); | |
} | |
// Uniting several RegExps into one | |
const rx = new RegExp( | |
[ | |
/(?:^(?:\.\s*)?([_a-zA-Z][_a-zA-Z0-9]*))/, |
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
<div id="parcel">📦</div> | |
<style> | |
#parcel { | |
position: absolute; | |
font-size: 4rem; | |
animation: jump 1.2s infinite; | |
} | |
@keyframes jump { | |
0% { transform: translate(-50%, -50%) scale(1.25, 0.75); } | |
50% { transform: translate(-50%, -150%) scale(1, 1); } |
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
const stepTimeout = 505; | |
const Router = (...chain) => | |
Object.assign( | |
async (ctx) => { | |
await (async function run(idx) { | |
if ("function" == typeof chain[idx]) { | |
await new Promise((res, rej) => { | |
const to = setTimeout( | |
() => rej(new Error(`Step [${idx}] timeout on \n${chain[idx]}`)), |
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
// Router is a function that returns async function. | |
const Router = (...chain) => | |
Object.assign( | |
// That async function as object have one method push() | |
async (ctx) => { | |
// When it calls that function it runs recursive algorithm | |
return await (async function run(idx) { | |
// Which calls each function in the chain | |
let res = await ("AsyncFunction" !== chain[idx].constructor.name | |
? new Promise((res) => chain[idx](ctx, res)) |
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 beautify( | |
/* HTML-string */ html, | |
/* new line chars */ nl = '\n', | |
/* indent chars */ tab = '\t', | |
/* disabled format tags */ disabled = /^(code|pre|em|strong|span|b|i|u|sup|sub|a)$/ig, | |
/* without closed tags */ single = /^(area|base|br|col|command|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/gi | |
){ | |
return escape( | |
stringify( | |
new DOMParser() /* parse HTML */ |
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 derelativePathD(d,fixed){ | |
let steps = d | |
.replace(/[,\s]+/g,' ') | |
.replace(/-\./g,'-0.') | |
.replace(/(?<=\.\d+)\./g,' 0.') | |
.split(/([MmLlAaCcSsQqTtVvHhZz])/g) | |
.splice(1) | |
.map((v,i) => !(i%2) ? v : v | |
.split(/\s+/g) | |
.map(v=>v.split(/(-?[\d]*(?:\.\d+)?(?:e-?\d{1,2})?)/g) |
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 floodFill(image, sr, sc, newColor) { | |
const current = image[sr][sc]; | |
if (current != newColor) { | |
fill(image, sr, sc, newColor, current); | |
} | |
return image; | |
function fill(image, sr, sc, newColor, current) { | |
if ( | |
sr < 0 || |
OlderNewer