Skip to content

Instantly share code, notes, and snippets.

View Terrance's full-sized avatar
🚒
​The world is quiet here.

Terrance Terrance

🚒
​The world is quiet here.
View GitHub Profile
@Terrance
Terrance / ytwm2gj.py
Last active June 6, 2025 19:44
Youtube Watchmarker to Grayjay history migration, using channel and video info from MW Metadata.
#!/usr/bin/env python3
"""
Youtube Watchmarker [1] to Grayjay [2] history migration, using channel
and video info from MW Metadata [3].
[1] https://github.com/sniklaus/youtube-watchmarker
[2] https://grayjay.app
[3] https://mattw.io/youtube-metadata
"""
@Terrance
Terrance / logcat.py
Last active April 23, 2025 22:05
Script to parse Android logcat entries, show package names, highlight by level and mute noise.
#!/usr/bin/env python3
import argparse
from collections import defaultdict
from datetime import date, datetime
import os.path
from pathlib import Path
import re
import subprocess
import sys
@Terrance
Terrance / apps.py
Last active April 17, 2025 22:23
Script to list installed apps on Android from the output of `dumpsys package packages`.
#!/usr/bin/env python3
from collections import defaultdict
import subprocess
USERS = {"0": "main", "10": "work"}
def style(text, *codes):
@Terrance
Terrance / ssh-tarpit.py
Created March 31, 2024 11:23
SSH tarpit server which accepts requests but stalls them with infinite SSH banners before accepting authentication.
#!/usr/bin/env python3
import asyncio
import logging
from random import randint
LOG = logging.getLogger(__name__)
HOST = "0.0.0.0"
@Terrance
Terrance / ulogger.py
Created March 31, 2024 10:57
Minimal, single-user μlogger server (https://github.com/bfabiszewski/ulogger-server) replacement, to accept location updates from μlogger for Android.
#!/usr/bin/env python3
"""
Credentials file (path in `ULOGGER_CREDS`):
```
<username>:<password>
```
Database schema (database name in `ULOGGER_DB`):
@Terrance
Terrance / vanilla-dl.py
Created March 30, 2024 22:57
Script to download all discussions and comments from a Vanilla forum as a set of JSON representation files.
#!/usr/bin/env python
from itertools import count
from pathlib import Path
import os
import sys
import requests
@Terrance
Terrance / apps.py
Created March 10, 2024 20:23
Script to list Android apps installed, grouped by installer, shown per-user (e.g. work profile). Intended to be ran via Termux.
#!/usr/bin/env python3
from collections import defaultdict
import subprocess
def main():
dumpsys = subprocess.run(("/system/bin/dumpsys", "package", "packages"), capture_output=True)
owners = defaultdict(set)
installs = defaultdict(dict)
@Terrance
Terrance / radicale-to-baikal.py
Created January 5, 2024 22:56
Script to migrate calendars and address books from a Radicale user collection to a Baikal principal (assuming a PostgreSQL database backend).
#!/usr/bin/env python3
"""
Migrate Radicale calendars and contacts to Baikal.
"""
import datetime
import json
import pathlib
import time
@Terrance
Terrance / readera-to-librera.py
Created May 8, 2023 22:08
Script to migrate reading history and highlights from Readera (reads from an unzipped backup file) to Librera (writes to a profile directory), a pair of Android reading apps.
#!/usr/bin/env python3
import hashlib
import json
import logging
import os.path
from pathlib import Path
LOG = logging.getLogger(__name__)
@Terrance
Terrance / conversations-backup-decrypt.py
Last active July 11, 2025 16:32
Methods to decrypt and re-encrypt database backups for Conversations, an Android XMPP client.
#!/usr/bin/env python3
from collections import defaultdict
from getpass import getpass
import gzip
import hashlib
import io
import json
import logging
import pathlib