Skip to content

Instantly share code, notes, and snippets.

bench / bench: jsdom (tests/bench/jsdom_vs_cheerio.spec.ts)
jsdom: parse only wall avg=112.8ms min=85.4ms max=150.9ms cpu avg=138.1ms
✔ parse only (1s)
jsdom: parse + querySelectorAll wall avg=131.7ms min=91.9ms max=300.8ms cpu avg=158.3ms
✔ parse + querySelectorAll (1s)
jsdom: parse + text node walk wall avg=145.5ms min=111.9ms max=183.4ms cpu avg=163.2ms
✔ parse + text node walk (2s)
jsdom: parse + setAttribute wall avg=113.2ms min=92.0ms max=129.1ms cpu avg=125.6ms
✔ parse + setAttribute (1s)
jsdom: parse + serialize wall avg=117.6ms min=96.9ms max=144.6ms cpu avg=129.9ms

Scoped mutex with timeouts and transaction convenience wrapper

It uses vercel/ms package to parse timeout

npm i ms @types/ms

Use it anywhere you want to serialize your code:

// Функция форматирования поля для ввода валюты
const setupCurrencyInput = (inputElement, options = {}) => {
// Определение конфигурации с валютой, разделителями и прочими параметрами
const config = {
currency: '₽', // Символ валюты
thousandsSeparator: ' ', // Разделитель тысяч
decimalSeparator: ',', // Разделитель десятичных
decimalPlaces: 0, // Количество десятичных знаков
hideZero: true, // Скрывать ноль, если значение 0
maxDigits: 9, // Максимальное количество цифр

Simple pagination builder for grammY

Relevant PR: grammyjs/menu#4

Current limitations and caveats

  • generator gets triggered at least two times per menu render (could be potentially fixed with caching by update_id)
  • generator has to load all of the items each time. Should instead pass range information to the builder and fetch only required items. This would also require a different method to fetch total count.
@lexuzieel
lexuzieel / README.md
Last active June 7, 2023 22:32
grammY menu history middleware

Usage

Extend your session data with navigation data flavor

export type SessionData = {
    // Your custom session data here
} & NavigationHistorySessionFlavor;
@lexuzieel
lexuzieel / backup.sh
Created February 24, 2022 13:14
Backup git diff or file to S3
#!/bin/bash
input=""
prefix=""
bucket=""
while [[ "$#" -gt 0 ]]; do
case $1 in
-p | --prefix)
shift
@lexuzieel
lexuzieel / runcached
Created May 8, 2021 15:47 — forked from akorn/runcached
Run speficied (presumably expensive) command with specified arguments and cache result. If cache is fresh enough, don't run command again but return cached output.
#!/bin/zsh
#
# Purpose: run speficied command with specified arguments and cache result. If cache is fresh enough, don't run command again but return cached output.
# Also cache exit status and stderr.
# Copyright (c) 2019-2020 András Korn; License: GPLv3
# Use silly long variable names to avoid clashing with whatever the invoked program might use
RUNCACHED_MAX_AGE=${RUNCACHED_MAX_AGE:-300}
RUNCACHED_IGNORE_ENV=${RUNCACHED_IGNORE_ENV:-0}
RUNCACHED_IGNORE_PWD=${RUNCACHED_IGNORE_PWD:-0}
#!/bin/bash
# REQUIREMENTS TO RUN THIS SCRIPT:
# - ffmpeg
# - python
# HOW TO RUN:
# - `cd` into the directory with `source.mp4`
# - Run this script
@lexuzieel
lexuzieel / asciinema-player.css
Created December 6, 2020 16:38
asciinema-player
.asciinema-player-wrapper {
position: relative;
text-align: center;
outline: none;
}
.asciinema-player-wrapper .title-bar {
display: none;
top: -78px;
transition: top 0.15s linear;
position: absolute;
@lexuzieel
lexuzieel / baka-mitai-first-order-model-demo.ipynb
Last active August 2, 2020 01:06
Baka Mitai first-order-model-demo.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.