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 / 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)
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 / 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) } '
@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"