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
import UnitOfDigital from './unit-of-digital.converter.js' | |
import UnitOfTime from './unit-of-time.converter.js' | |
export { | |
UnitOfDigital, | |
UnitOfTime, | |
} |
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
import { UnitOfTime } from './converter.js' | |
function timing(fn) { | |
let perf = performance | |
let A = perf.now() | |
let result = fn() | |
let B = perf.now() | |
return [result, B - A] | |
} | |
async function timingAsync(asyncFn) { |
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 M.setup(opts) | |
-- Look up keys in user-defined table with fallback to defaults. | |
M.opts = setmetatable(opts or {}, {__index = require'app.defaults'}) | |
M.initialized = true | |
-- Insert the engine and register the autocommand if asked to. | |
local engine = require'app.engine' | |
-- engine.do_work() | |
if M.opts.create_app_autocmd then |
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
// Detects encoding of a buffer | |
exports.detectEncoding = function (buffer) { | |
for (var i = 0; i < buffer.length; i++) { | |
if (buffer[i] === 65533 || buffer[i] <= 8) { | |
// The character code 65533 is often used as a replacement character for an unknown or unprintable character in a text file. | |
// The check for values less than or equal to 8 is intended to exclude control characters which are typically not part of human-readable text. | |
return 'binary' | |
} | |
} | |
return 'utf8' |
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
#!/bin/bash | |
# process 1: | |
$ mkdir /tmp/anything # create entry | |
$ exec 42> /tmp/anything/42 # open write on 42 | |
$ echo "message here" >&42 # write message to 42 | |
$ exec 42>&- # close write 42 | |
# process 2: | |
$ exec 42< /tmp/anything/42 # open read on 42 | |
$ cat <&42 # read from 42 and pipe to cat |
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 npm commit: https://github.com/npm/cli/commit/4626dfa73 |
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
// ISO 3166-1 alpha-2 | |
// ⚠️ No support for IE 11 | |
// Source: all over the internet | |
function countryToFlag(code) { | |
let isoCode = code.split("-").pop() | |
return typeof String.fromCodePoint !== 'undefined' | |
? isoCode | |
.toUpperCase() | |
.replace(/./g, (char) => String.fromCodePoint(char.charCodeAt(0) + 127397)) | |
: isoCode; |
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 getAllCombinations = (arraysToCombine) => { | |
const divisors = []; | |
let permsCount = 1; | |
for (let i = arraysToCombine.length - 1; i >= 0; i--) { | |
divisors[i] = divisors[i + 1] ? divisors[i + 1] * arraysToCombine[i + 1].length : 1; | |
permsCount *= (arraysToCombine[i].length || 1); | |
} | |
const getCombination = (n, arrays, divisors) => arrays.reduce((acc, arr, i) => { | |
acc.push(arr[Math.floor(n / divisors[i]) % arr.length]); |
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 filterBy = (conditions, index = 0) => (value) => { | |
if(conditions[index] === undefined) return value | |
if(!conditions[index](value)) return | |
return filterBy(conditions, index + 1)(value) | |
} | |
const values = [1, 2, 3, 4, 5, 6, 7, 8, 9 , 10, 25, 27] | |
const odd = (value) => value % 2 !== 0 | |
const greaterThan3 = (value) => value > 3 | |
const canDivide3 = (value) => value % 3 === 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
Schema Registry Editor | |
Inactive | |
focus -> Active | |
Active | |
showHelper -> Active | |
createSchema -> Editable | |
Editable | |
createField -> Editable | |
deleteField -> Editable | |
updateField -> Editable |
NewerOlder