Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

alekssamos

🎯
Focusing
View GitHub Profile
@alekssamos
alekssamos / persistentset.py
Last active February 18, 2023 11:31
How can I make a permanent (between restarts) set or any other object
View persistentset.py
from threading import Lock
import os, os.path
try:
import dill as pickle
import dill.settings
from dill import FILE_FMODE
dill.settings.update({'byref': True, 'fmode': FILE_FMODE, 'recurse': True, 'ignore': True})
except ImportError:
import pickle
@alekssamos
alekssamos / persistentqueue.py
Created February 3, 2023 15:40
Persistent queue with saving to disk (Python)
View persistentqueue.py
"""
Persistent queue
A permanent queue with saving to disk. It is restored on restart.
Only waiting new elements that have not yet been taken into operation will be restored.
Source:
Persistent Queue « Python recipes « ActiveState Code
https://code.activestate.com/recipes/579124-persistent-queue/
PERSISTENT QUEUE (PYTHON RECIPE)
@alekssamos
alekssamos / queue.sh
Created November 12, 2022 13:10 — forked from erichschroeter/queue.sh
Shell script implementation of a Queue.
View queue.sh
#!/bin/bash
#
# This script encapsulates the functionality of a queue. It requires there to be
# an input file with the data in the queue being separated on different lines.
#
INPUT=queue.txt
OUTPUT=trash.txt
CMD=/usr/bin/vlc
@alekssamos
alekssamos / Dockerfile
Created October 2, 2022 08:43 — forked from WoozyMasta/Dockerfile
An example of building a Python application into a self-contained statically linked binary and packaging it into a container image based on scratch
View Dockerfile
FROM docker.io/python:3.9-bullseye AS build
WORKDIR "/app"
# Install dependecies
# hadolint ignore=DL3008,DL3013
RUN set -eux && \
apt-get update; \
apt-get install --no-install-recommends -y \
python3-dev build-essential patchelf upx; \
apt-get clean; \
@alekssamos
alekssamos / supervisor
Created July 25, 2022 15:49 — forked from glarrain/supervisor
logrotate.d/supervisor: config file for logrotate for Supervisor logs (includes explanation of each directive)
View supervisor
/var/log/supervisor/*.log {
weekly
rotate 52
compress
delaycompress
notifempty
missingok
copytruncate
}
@alekssamos
alekssamos / pre-commit
Created July 19, 2022 16:00 — forked from josep11/pre-commit
pre-commit hook to run unit tests
View pre-commit
#!/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
View ACCESSIBILITY_ENABLE.md

Если экранный диктор 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)
View conversation.py
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
View __main__.py
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.
View ym_recognition.py
"""
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