Skip to content

Instantly share code, notes, and snippets.

View Beaglefoot's full-sized avatar

Stanislav Chernov Beaglefoot

  • Moscow, Zelenograd
View GitHub Profile
@Beaglefoot
Beaglefoot / pyproject.toml
Created October 18, 2022 19:39
Poetry 1.2 cannot find boto3-stubs[s3]==1.16.7
[tool.poetry]
name = "test-app"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
readme = "README.md"
packages = [{include = "test_app"}]
[tool.poetry.dependencies]
python = "^3.8"
@Beaglefoot
Beaglefoot / avg_cpu_load.sh
Created August 4, 2022 15:24
avg_cpu_load
#!/bin/bash
cat /proc/stat | awk ' $1 == "cpu" { idle_time = $5; for (i = 2; i <= 10; i++) total_time += $i } END { print 100 - 100 * (idle_time / total_time) } '
from contextlib import contextmanager
import os
import sys
from pprint import pprint
def get_python_version(venv_path: str) -> str:
version = ""
with open(os.path.join(venv_path, "pyvenv.cfg")) as cfg:
@Beaglefoot
Beaglefoot / mergeIntervals.ts
Last active November 23, 2021 09:29
algo test
/*
arr - массив строк вида ["1-3","5-7","2-4","8-12","5-11"]
Каждая строка в массиве задает интервал [N,M], где N и M - целые числа, включая края.
Необходимо написать функцию сигнатуры string[] => string[], которая получает на вход подобный массив,
и возвращает массив строк такого же формата, в котором все перекрывающиеся интервалы оптимально склеены и отсортированы.
Например, в данном случае должен получиться массив ["1-4","5-12"].
Необходимо учесть возможные пограничные случаи, включая невалидный формат"
*/
function parseInterval(interval: string): { start: number; end: number } {
@Beaglefoot
Beaglefoot / concurrentGen.ts
Created November 13, 2021 20:22
Executes array of promise-returning functions with provided concurrency level
type Task<R> = () => Promise<R>
/** Execute array of promise-returning functions with provided concurrency level */
async function* concurrentGen<R>(tasks: Task<R>[], concurrency: number) {
async function withIndex(task: Task<R>, index: number) {
const result = await task()
return { result, index }
}
const queues = tasks.splice(0, concurrency).map(withIndex)
#!/usr/bin/bash
function h2s() {
local hours=$1
echo "${wait_time:0:-1} * 3600" | bc | cut -d. -f1
}
function humanize_duration() {
local total_seconds=$1
local hours=$(( $total_seconds / 3600 ))
@Beaglefoot
Beaglefoot / script.typescript
Created December 14, 2019 17:12
Simple TreeSelect (with vanillaTS)
console.clear();
enum FoldIcon {
folded = '+',
unfolded = '-'
}
interface IData {
id: number;
title: string;
@Beaglefoot
Beaglefoot / index.html
Created October 12, 2019 08:15
Simple Toast Notifications (with vanillaJS)
<div class="buttons">
<button class="button__success">Success</button>
<button class="button__info">Info</button>
<button class="button__warning">Warning</button>
<button class="button__error">Error</button>
</div>