Skip to content

Instantly share code, notes, and snippets.

View alekssamos's full-sized avatar
🎯
Focusing

alekssamos

🎯
Focusing
View GitHub Profile
@alekssamos
alekssamos / pre-commit
Created July 19, 2022 16:00 — forked from josep11/pre-commit
pre-commit hook to run unit tests
#!/bin/bash
current_branch=`git rev-parse --abbrev-ref HEAD`
if [[ $current_branch =~ master|main ]]; then
message="Please don't push directly to $current_branch."
echo -e "\033[1;31mERROR: $message\033[0m";
exit 1
fi
repo_dir=`git rev-parse --show-toplevel`
@alekssamos
alekssamos / ACCESSIBILITY_ENABLE.md
Last active June 21, 2022 17:25
включить доступность / enable accessibility Orca

Если экранный диктор Orca не работает в некоторых приложениях сделайте следующее:

export ACCESSIBILITY_ENABLED=1
export GTK_MODULES=gail:atk-bridge
export GNOME_ACCESSIBILITY=1
export QT_ACCESSIBILITY=1
export QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1

Откройте на редактирование файл ~/.profile и впишите их туда, для автоматического назначения этих переменных окружения при входе в систему.

@alekssamos
alekssamos / conversation.py
Created January 25, 2022 06:34 — forked from M-S-2-7/conversation.py
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
@alekssamos
alekssamos / __main__.py
Created December 12, 2021 15:10
lg tv webos toggle audio guide for blind
import os, os.path
import pickle
import time
from pywebostv.discovery import * # Because I'm lazy, don't do this.
from pywebostv.connection import *
from pywebostv.controls import *
filename = os.path.join(os.path.expanduser("~"), "lgtvst.pickle")
# 1. For the first run, pass in an empty dictionary object. Empty store leads to an Authentication prompt on TV.
# 2. Go through the registration process. `store` gets populated in the process.
# 3. Persist the `store` state to disk.
@alekssamos
alekssamos / ym_recognition.py
Created December 4, 2021 09:50 — forked from teidesu/ym_recognition.py
small script that (ab)uses Yandex Music Recognition.
"""
This is small script that (ab)uses Yandex Music Recognition.
I hope the code is self-documented <3
Notice! Input file should be .ogg file, preferably with libopus encoder
(untested with other encoders)
(c) teidesu, 2019. This script is licensed under GPLv3 license.
"""
import lomond
import uuid as uuid_py
@alekssamos
alekssamos / taskpool.py
Created October 20, 2021 10:15 — forked from mdellavo/taskpool.py
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)
@alekssamos
alekssamos / asyncio_pool.py
Created October 20, 2021 09:43 — forked from njam/asyncio_pool.py
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 / download_multiple.py
Created October 7, 2021 05:36 — forked from Hammer2900/download_multiple.py
Use asyncio and aiohttp to asynchronously download multiple files at once and handle the responses as they finish
import asyncio
from contextlib import closing
import aiohttp
async def download_file(session: aiohttp.ClientSession, url: str):
async with session.get(url) as response:
assert response.status == 200
# For large files use response.content.read(chunk_size) instead.
@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 = '';
@alekssamos
alekssamos / kali_sound.sh
Created July 27, 2021 16:43
Fix sound Kali linux
#!/bin/bash
## http://helpexe.ru/programmirovanie/kak-vkljuchit-zvuk-v-kali-linux
# Check the script is being run by root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root"
exit 1
fi