Skip to content

Instantly share code, notes, and snippets.

View eprigorodov's full-sized avatar

Evgeny Prigorodov eprigorodov

View GitHub Profile
@eprigorodov
eprigorodov / find_snapshot.py
Created December 18, 2020 09:59
Helper script for finding an ID of restic snapshot that was taken before|after the given date. Usage: restic snapshots --json | find_snapshot.py <before|after> YYYY-MM-DD.HH
#!/usr/bin/env python3
from datetime import datetime, time, timedelta, timezone
import json
import operator
import sys
try:
parse = datetime.fromisoformat
@eprigorodov
eprigorodov / beep.s
Last active September 14, 2023 12:05
Small program in GNU assembler to test the code that beeps PC speaker. The beep is to be put into kernel (wakeup_64.S), to find out at which stage resume crashes.
# compile: gcc -o beep.o -c beep.s ; ld -o beep beep.o
# run: sudo ./beep, non-root userspace code is not allowed to use port IO
.global _start
.text
_start:
# ioperm(0x42, 32, 1)
mov $173, %rax # ioperm() == 173 in x86_64
mov $0x42, %rdi # from port 0x42
@eprigorodov
eprigorodov / zcatalog_caching_race.py
Last active April 10, 2018 19:29
Race scenario for andbag-zcatalog-caching branch of zopefoundation/Products.ZCatalog
from __future__ import print_function
from persistent import Persistent
from threading import current_thread, Event, local, Lock, Thread
import sys
import transaction
from ZODB import DB
from ZODB.DemoStorage import DemoStorage
from ZODB.POSException import ConflictError