Skip to content

Instantly share code, notes, and snippets.

View martinkozle's full-sized avatar

Martin Popovski martinkozle

View GitHub Profile
@martinkozle
martinkozle / hyprland.conf
Created May 23, 2024 23:03
Hyprland bind for switching all keyboard layouts, handling inconsistencies
# Switch keyboard layout (inline)
bind = $mainMod, SPACE, exec, switch=$(hyprctl devices -j | jq -r '.keyboards[] | .active_keymap' | uniq -c | [ $(wc -l) -eq 1 ] && echo "next" || echo "0"); for device in $(hyprctl devices -j | jq -r '.keyboards[] | .name'); do hyprctl switchxkblayout $device $switch; done; activeKeymap=$(hyprctl devices -j | jq -r '.keyboards[0] | .active_keymap'); if [ $switch == "0" ]; then resetStr="(reset)"; else resetStr=""; fi; hyprctl notify -1 1500 0 "$activeKeymap $resetStr";
# Switch keyboard layout (shell script)
bind = $mainMod, SPACE, exec, ~/somewhere/switch_layout.sh
@martinkozle
martinkozle / celery.py
Last active July 10, 2024 00:32
Celery Pydantic Task PoC
import celery
from tasks import FooTask
app = celery.Celery(
"app",
broker="amqp://",
)
FooTask.register_for_app(app)
@martinkozle
martinkozle / main.py
Created February 13, 2024 05:47
GTA 5 MAX INT Billionaire
import heapq
from collections import defaultdict
from dataclasses import dataclass, field
from enum import Enum, auto
class Step(Enum):
A = auto()
B = auto()
C = auto()
@martinkozle
martinkozle / sync_to_async_iter.py
Last active July 14, 2023 13:09
Asynchronously iterate a synchronous IO blocking iterator using a thread pool
import asyncio
from concurrent.futures import ThreadPoolExecutor
from functools import partial
from typing import AsyncIterator, Iterator, TypeVar
T = TypeVar("T")
def checked_next(iterator: Iterator[T]) -> T | None:
try: