type AA = Partial<Record<'next' | 'back' | 'hideOthers', string>> type BB = Record<'next' | 'back' | 'hideOthers', string>
const aa: AA = { next: 'adads' }
type FN = (a: Record<string, string>) => void
const fx: FN = (bb) => console.log(bb)
type AA = Partial<Record<'next' | 'back' | 'hideOthers', string>> type BB = Record<'next' | 'back' | 'hideOthers', string>
const aa: AA = { next: 'adads' }
type FN = (a: Record<string, string>) => void
const fx: FN = (bb) => console.log(bb)
type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` | |
? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` | |
: Lowercase<S> | |
type KeysToCamelCase<T> = { | |
[K in keyof T as CamelCase<string & K>]: T[K] | |
} | |
type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}` ? |
const fx = (fn, start, ...xn) => { | |
const FF = class { | |
constructor (...rn) { | |
const ww = (...wn) => { return new FF(...rn, ...wn)} | |
ww.valueOf = () => this.valueOf() | |
ww.toString = () => this.toString() | |
this.items = rn |
const toDigit = (...values) => { | |
const isValue = x => x != null && !isNaN(x) && isFinite(x); | |
return +values.find(isValue) || 0; | |
} | |
const toDigit = (...values) => +values.find(x => x != null && !isNaN(x) && isFinite(x)) || 0; |
// const freezeFn = fn => (c => x => c[x] != null ? c[x] : c[x] = fn(x))({}) | |
const freezeFn = fn => (c => {return function cached(x){if (c[x] != null) {c[x] = fn(x, cached)}; return c[x]}})({}) | |
const fibFn = (x, fn) => fn(x - 1) + fn(x - 2) | |
const fibArgs = (x, fn) => +!parseInt(x) || +(x == 0) || +(x == 1) || fibFn(parseInt(x), fn) | |
const fibonacci = freezeFn(fibArgs) | |
const facFn = (x, fn) => x * fn(x - 1) | |
const facArgs = (x, fn) => +!parseInt(x) || +(x == 0) || +(x == 1) || facFn(parseInt(x), fn) | |
const factorial = freezeFn(facArgs) |
const fnBy = fn => x => y => !fn || !Math[fn] || !x || !y ? 0 : y < 0 ? 0 : y > x ? x : Math[fn] (10 * y / x) * x / 10; | |
// const ceilBy = max => y => !max || !y ? 0 : y < 0 ? 0 : y > max ? max : Math.ceil (10 * y / max) * max / 10; | |
const ceilBy = fnBy('ceil'); | |
const roundBy = fnBy('round'); | |
const floorBy = fnBy('floor'); | |
const fiveStarRating = ceilBy(5); | |
const oneHundredPoints = roundBy(100); | |
// Example |
<script id="nb-loader-script"> | |
(function(url) { | |
// document.currentScript works on most browsers, but not all | |
var where = document.currentScript || document.getElementById("nb-loader-script"), | |
promoted = false, | |
LOADER_TIMEOUT = 3000, | |
IDPREFIX = "__nb-script"; | |
// function to promote a preload link node to an async script node |
server { | |
listen 80; | |
server_name {}; | |
set $MAGE_MODE developer; | |
set $MAGE_RUN_TYPE website; | |
set $MAGE_RUN_CODE {}; | |
set $MAGE_ROOT /var/www/{}; |
<div data-role="instafeed" class="instafeed-container"></div> | |
<script type="text/x-magento-init"> | |
{ | |
"[data-role=instafeed]": { | |
"instafeed-loader": { | |
"userId": "{{userId}}", // https://stackoverflow.com/q/11796349 | |
"accessToken": "{{accessToken}}" // https://www.instagram.com/developer/authentication/ | |
} | |
} | |
} |