Skip to content

Instantly share code, notes, and snippets.

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.
@lexuzieel
lexuzieel / nginx.conf
Created May 20, 2020 10:08 — forked from li0nel/nginx.conf
Nginx config for Laravel
fastcgi_cache_path /dev/shm levels=1:2 keys_zone=laravel:100m;
fastcgi_cache_key "$scheme$request_method$host$request_uri$query_string";
server {
listen 80 default_server;
server_name laravel.info;
root /usr/share/nginx/html/;
index index.php index.html;