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
let storedSeed: number = 1337; | |
// MurmurHash3 | |
export function seed(str: string): void { | |
for(let i = 0, h = 1779033703 ^ str.length; i < str.length; i++) { | |
h = Math.imul(h ^ str.charCodeAt(i), 3432918353), | |
h = h << 13 | h >>> 19; | |
if (i === str.length - 1) { | |
storedSeed = h; |
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 path = require("node:path"); | |
const webpack = require("webpack"); | |
const { SwcMinifyWebpackPlugin } = require('swc-minify-webpack-plugin'); | |
module.exports = { | |
mode: "production", | |
target: "node22", | |
context: path.resolve(__dirname), | |
entry: { | |
server: path.resolve(__dirname, "../src/server.ts"), |
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
export type TFuture<T> = () => Promise<T> | |
export type TQueueOptions<T> = { | |
maxActiveRequests?: number | |
dataHandler?: (data: T) => void | |
errorHandler?: (error: Error) => void | |
retries?: number | |
doneCallback?: (error?: Error, data?: Array<Error | T | undefined>) => void | |
failOnError?: boolean | |
} |
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
// Run Node.js process with --require flag: | |
// $ node index.js -r register.js | |
// ...or with NODE_OPTIONS env variable: | |
// $ NODE_OPTIONS="-r register.js" node index.js | |
const style1 = require('./src/styles.less'); | |
const style2 = require('./src/styles.less?raw'); | |
console.log(style1, style2); |
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 linearToLogarithmic(linearValue: number, minValue: number, maxValue: number) { | |
const range = maxValue - minValue; | |
let value = Math.round(Math.pow(range + 1, linearValue) + minValue - 1); | |
if (value < minValue) { | |
value = minValue; | |
} else if (value > maxValue) { | |
value = maxValue; | |
} |
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
/** | |
* Return string that represent element position in DOM (usually valid CSS selector). Position is relative to document.body. | |
* | |
* ATTENTION! | |
* If you use shadow DOM on the page, this function will not return valid CSS selector. | |
*/ | |
export function getPath(element: Element) { | |
const stack = []; | |
let el = element; | |
while (!!el.parentNode) { |
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
/** | |
* Super simple function to parse date string (date.toLocaleDateString()) | |
* It's not bullet-proof, so for more stable parsing use something like moment.js | |
* | |
* This function may return invalid date object if the string was not parsed correctly. | |
* Check for validity: | |
* | |
* isNaN(date.valueOf()) // Invalid date if true | |
*/ | |
private parseLocaleDateString = (localeDate?: string): Date => { |
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
################# | |
# Custom prompt # | |
################# | |
txtrst='\e[0m' | |
fgW='\e[38;5;7m' | |
bgDG1='\e[48;5;235m' | |
fgDG1='\e[38;5;235m' | |
bgDG2='\e[48;5;237m' | |
fgDG2='\e[38;5;237m' | |
bgDG3='\e[48;5;239m' |