Skip to content

Instantly share code, notes, and snippets.

View svaningelgem's full-sized avatar

Steven Van Ingelgem svaningelgem

View GitHub Profile
@svaningelgem
svaningelgem / stocard_to_catima_zip.py
Created October 11, 2025 12:58
Convert Stocard database into export file for Catima
import json
import sqlite3
import zipfile
from pathlib import Path
from collections import defaultdict
def is_image(content_bytes: bytes) -> tuple[bool, str | None]:
"""Check if content is an image and return format"""
if content_bytes.startswith(b'\x89PNG'):
@svaningelgem
svaningelgem / convert_to_pdf.py
Created April 17, 2023 19:06
How to convert html files into PDF via playwright.
from pathlib import Path
from playwright import sync_api
dirs = {
'1': 'book1',
'2': 'book2',
}
@svaningelgem
svaningelgem / change logging to lazy logging.py
Created February 19, 2023 09:28
Quick and dirty script to convert any possible log pattern in a directory to lazy logging.
import re
from pathlib import Path
search_patterns = [
re.compile(r"logger\s*\.(?P<method>.*)\(\s*f", flags=re.IGNORECASE),
re.compile(r"logging.getLogger\s*(?P<method>.*)\(\s*f", flags=re.IGNORECASE),
]
@svaningelgem
svaningelgem / Pocketland.trip_creator.py
Created February 17, 2023 01:42
automated way of generating a path for "Click Assistant - Auto Clicker" (search for com.rise.automatic.autoclicker.clicker) for the game "Pocket Land" (search for gs.hadi.pocketisland).
import json
import subprocess
from pathlib import Path
aantal = 9
vertical_time = 4000
horizontal_time = 550
run_every_x_sec = 300
target_file_local = Path.home() / "Downloads/Pocketland"
target_file_adb = "/sdcard/com.rise.automatic.autoclicker.clicker/config/" + target_file_local.name
#include <dde.h>
HDDEDATA CALLBACK DdeCallback(
UINT uType,
UINT uFmt,
HCONV hconv,
HSZ hsz1,
HSZ hsz2,
HDDEDATA hdata,
ULONG_PTR dwData1,
@svaningelgem
svaningelgem / scramble_words.py
Created June 12, 2021 19:45
Scramble any text, but keep it readable for normal humans.
txt = """This text is a small demonstration about the fact that the human brain can read texts, even though a computer is not able to make sense of it."""
# Outputs like: Tihs txet is a slmal dntaoistroemn abuot the fcat that the hmuan bairn can raed tetxs, eevn tuhogh a comupter is not able to make ssene of it.
from random import shuffle
import re
x = re.split(r'([^a-z]+)', txt, flags=re.IGNORECASE)
# print(x)
@svaningelgem
svaningelgem / decrypt.sh
Created December 24, 2020 08:20
Decrypt PDF without knowing the password
#!/bin/bash
# Basically this is just reading the pdf & writing it out again...
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f encrypted.pdf
@svaningelgem
svaningelgem / wrk_script.lua
Last active April 19, 2020 20:27
Stress test of a server using "wrk" (an apachebench "ab" alternative). It loads urls from a file.
-- shows the percentiles after its run.
-- run like:
-- wrk --duration 10s --threads 10 --timeout 5s "http://example.com" --script script.lua
local fp = nil;
local ips = {
'ip1',
'ip2',
'ip3'
}