Skip to content

Instantly share code, notes, and snippets.

View alekssamos's full-sized avatar
🎯
Focusing

alekssamos

🎯
Focusing
View GitHub Profile
@njam
njam / asyncio_pool.py
Created October 13, 2017 18:24
Limit number of concurrently running asyncio tasks
import asyncio
from collections import deque
class AsyncioPool:
def __init__(self, concurrency, loop=None):
"""
@param loop: asyncio loop
@param concurrency: Maximum number of concurrently running tasks
"""
@alekssamos
alekssamos / a.js
Created September 21, 2021 16:33 — forked from Dobby233Liu/a.js
my messing w/ msedge dev read aloud. ONLY RUN IN edge dev. i give up, so it wont work properly
var ARRAY_LENGTH = 16;
var MIN_HEX_LENGTH = 2;
class UUID {
static createUUID() {
const array = new Uint8Array(ARRAY_LENGTH);
window.crypto.getRandomValues(array);
let uuid = '';
@mdellavo
mdellavo / taskpool.py
Created April 24, 2017 00:28
asyncio task pool
import asyncio
from asyncio.queues import Queue
TERMINATOR = object()
class TaskPool(object):
def __init__(self, loop, num_workers):
self.loop = loop
self.tasks = Queue(loop=self.loop)
@kuntalchandra
kuntalchandra / print_random.py
Created August 22, 2019 13:06
Python: MagicMock, Patch and Side effect
import time
import uuid
class PrintRandom(object):
def execute(self) -> None:
while True:
self.print_number(uuid.uuid1().int)
time.sleep(1)
@glarrain
glarrain / supervisor
Created August 6, 2013 16:14
logrotate.d/supervisor: config file for logrotate for Supervisor logs (includes explanation of each directive)
/var/log/supervisor/*.log {
weekly
rotate 52
compress
delaycompress
notifempty
missingok
copytruncate
}
@Dobby233Liu
Dobby233Liu / a.js
Last active October 23, 2022 08:58
my messing w/ msedge dev read aloud. ONLY RUN IN edge dev. i give up, so it wont work properly
var ARRAY_LENGTH = 16;
var MIN_HEX_LENGTH = 2;
class UUID {
static createUUID() {
const array = new Uint8Array(ARRAY_LENGTH);
window.crypto.getRandomValues(array);
let uuid = '';
@M-S-2-7
M-S-2-7 / conversation.py
Last active August 22, 2023 16:25
Conversations in pyrogram (no extra package needed)
from pyrogram import Client, filters
app = Client('CONVERSATION_EXAMPLE')
conversations = {}
infos = {}
def conv_filter(conversation_level):
def func(_, __, message):
return conversations.get(message.from_user.id) == conversation_level
@CoolOppo
CoolOppo / Cargo.toml
Last active January 2, 2024 10:27
How to compile to a DLL in rust while using it as a normal rust library
[package]
name = "test"
version = "0.1.0"
authors = ["YOU <YOU@users.noreply.github.com>"]
edition = "2018"
[lib]
crate-type = ["cdylib"]
@jirihnidek
jirihnidek / sub-sub-command.py
Last active February 17, 2024 14:18
Python example of using argparse sub-parser, sub-commands and sub-sub-commands
"""
Example of using sub-parser, sub-commands and sub-sub-commands :-)
"""
import argparse
def main(args):
"""
Just do something
@alexeygrigorev
alexeygrigorev / tqdm_pool.py
Created December 6, 2018 15:36
Track progress of ProcessPoolExecutor with tqdm
from glob import glob
import multiprocessing
from concurrent.futures import ProcessPoolExecutor
import cv2
from PIL import Image
import imagehash
from tqdm import tqdm