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
/** @typedef {[number,number,number,number,number,number]} Matrix*/ | |
const transformApply = (/**@type {Matrix} */matrix, point=[0,0]) => { | |
// extract the transformation matrix values | |
const [scaleX, skewY, skewX, scaleY, translateX, translateY] = matrix | |
const [x, y] = point | |
// apply the transformation matrix to the point | |
return [ | |
x * scaleX + y * skewX + translateX, | |
x * skewY + y * scaleY + translateY |
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
# first create a branch in the parent repo | |
git subtree split -P path/to/folder/toExtract --branch branchName | |
# then create the directory for the external repo | |
mkdir myNewRepo | |
cd myNewRepo | |
git init | |
git remote add tempRemote path/to/parent/repo | |
# only getch what is needed no more to avoid cluttered git reflog in the new repo | |
git fetch --no-tags tempRemote branchName |
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 getMapMaxValueKey = (map) => { | |
return map.size ? [...map.entries()] | |
.reduce((a, b) => a[1] >= b[1] ? a : b)[0] | |
: null | |
} |
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
-- deactivates all triggers and constraints | |
SET session_replication_role = replica; | |
-- restore triggers and constraints | |
SET session_replication_role = DEFAULT; | |
-- treat out-of-sync auto-increment sequence fields (use double quote arround table names to preserve uppercase letters) | |
SELECT pg_catalog.setval(pg_get_serial_sequence('"table_name"', 'id'), MAX(id)) FROM "table_name"; |
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
function urlBase64ToUint8Array(base64String) { | |
const padding = '='.repeat((4 - base64String.length % 4) % 4); | |
const base64 = (base64String + padding) | |
.replace(/\-/g, '+') | |
.replace(/_/g, '/') | |
; | |
const rawData = window.atob(base64); | |
return Uint8Array.from([...rawData].map((char) => char.charCodeAt(0))); | |
} |
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 tpl = makeTemplate('hello ${name}') | |
//const name = 'world'; | |
//tpl({name}); | |
const makeTemplate = (templateString) => { | |
return (templateData) => new Function(`{${Object.keys(templateData).join(',')}}`, 'return `' + templateString + '`')(templateData); | |
} |
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 notificationGrantedPromise = () => { | |
if (!('Notification' in window)) { | |
return Promise.reject(); | |
} | |
return (Notification.permission !== 'default') ? Promise.resolve(Notification.permission) : Notification.requestPermission(); | |
}; | |
const notify = (...args) => notificationGrantedPromise().then((permission) => permission === 'granted' ? new Notification(...args) : null); |
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 enchainProxifier = (target, promise = Promise.resolve()) => { | |
return new Proxy(target, { | |
get(target, propName) { | |
if (propName === 'promise') { | |
return promise; | |
} else if (propName === 'then') { | |
return (...args) => promise.then(...args); | |
} | |
if (target[propName] instanceof Function) { | |
return (...args) => enchainProxifier(target, promise.then(() => target[propName](...args))); |
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
/* | |
EXAMPLE MESSAGE | |
!poll question? | |
option 1 | |
option 2 | |
*/ | |
class Script { | |
/** | |
* @params {object} request |
NewerOlder