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
| # Ensure a managed config block exists exactly once in a file (idempotent). | |
| # - If the block already exists (identified by begin/end marker lines), it is replaced. | |
| # - If it doesn't exist, it is appended. | |
| # - Works for root-owned files via sudo by writing to a temp file then installing. | |
| # - Callers do not need a trailing newline in <content>. | |
| # | |
| # Usage: | |
| # ensure_block <file> <id> <content> [sudo] | |
| # | |
| # # Append (or replace) a managed block containing 'export FOO=bar' in |
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
| import { KeyObject, createECDH, createPrivateKey } from "node:crypto"; | |
| /** | |
| * The size of the private key for P-384 in bytes. | |
| * 384 bits / 8 = 48 bytes | |
| */ | |
| const P384_BYTE_LENGTH = 48; | |
| export interface DeriveEcPrivateKeyArgs { | |
| /** A high entropy, uniformly random secret. Must have at least 384 bits of entropy and must be uniformly random. */ |
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
| type NonUndefined<T> = T extends undefined ? never : T; | |
| /** | |
| * Create an object with a single property, if the value is not undefined. | |
| * Guarantees you don't have `{ myKey: undefined }` in your object. | |
| * | |
| * @param keyName the name of the key | |
| * @param value the value which may be undefined | |
| * @returns an object which should be spread into a parent object |
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
| /******************* | |
| * Scrollbar | |
| *******************/ | |
| /** Scrollbar style override */ | |
| .scroller { | |
| overflow-x: hidden; | |
| overflow-y: scroll; | |
| border-color: rgba(0, 0, 0, 0); | |
| transition-timing-function: ease-in-out; |
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 exclusions = [ | |
| ' Inc.', | |
| ', Inc.', | |
| 'The ', | |
| '.com', | |
| ]; | |
| /** | |
| * Exclude words from matching score. See exclusions above. | |
| */ |
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
| // local | |
| import { LanguageKey } from './enums'; | |
| /** | |
| * Language name should be written in own language | |
| */ | |
| export const nativeLanguageNames: Record<LanguageKey, string> = { | |
| /* English */ | |
| [LanguageKey.En]: 'English', | |
| /* Arabic */ |
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 a file to be imported by both Node and Browser. | |
| * | |
| * module.exports = sharedFunction; | |
| * AND | |
| * export default sharedFunction; | |
| */ | |
| // shared-code.js | |
| function sharedFunction(x) { | |
| return x * 2; |
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(XHR) { | |
| var open = XHR.prototype.open; | |
| var send = XHR.prototype.send; | |
| XHR.prototype.open = function(method, url, async, user, pass) { | |
| this._url = url; | |
| open.call(this, method, url, async, user, pass); | |
| }; | |
| XHR.prototype.send = function(data) { |
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
| // Generates an elliptic curve keypair for the purpose of signing JWTs with ECDSA. | |
| const jose = require('node-jose'); | |
| const fs = require('fs'); | |
| const keystore = jose.JWK.createKeyStore(); | |
| async function addNewECDSAKey(kid, keystore) { | |
| const kty = "EC"; | |
| const crv = "P-384"; |
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
| // https://nodejs.org/api/process.html#process_process_memoryusage | |
| let rssMax = heapTotalMax = heapUsedMax = externalMax = 0; | |
| let rssMin = heapTotalMin = heapUsedMin = externalMin = Number.MAX_SAFE_INTEGER; | |
| readable.on('data', () => { | |
| const x = process.memoryUsage(); | |
| if (x.rss > rssMax) rssMax = x.rss; | |
| if (x.heapTotal > heapTotalMax) heapTotalMax = x.heapTotal; | |
| if (x.heapUsed > heapUsedMax) heapUsedMax = x.heapUsed; |
NewerOlder