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 / hh3.py
Created May 21, 2021 15:01
Script to produce tables of data from a BT Home Hub 3 router.
#!/usr/bin/env python3
from base64 import b64encode
from collections import namedtuple
from datetime import timedelta
from hashlib import md5
import re
from bs4 import BeautifulSoup
from requests import Session
@Terrance
Terrance / ticktick2cal.py
Created May 21, 2021 15:02
Script to convert from TickTick's backup CSV file to CalDAV-compatible VTODO files.
#!/usr/bin/env python3
from csv import DictReader
from datetime import datetime
from dateutil.rrule import rrulestr
from icalendar import Alarm, Calendar, Todo, vRecur
PRIORITY = {"0": "0", "1": "6", "3": "5", "5": "4"}
@Terrance
Terrance / sleep2cal.py
Created May 21, 2021 15:02
Script to convert from Sleep as Android's backup CSV file (the path assuming a Termux environment) to CalDAV-compatible VEVENT files.
#!/usr/bin/env python3
from csv import DictReader
from datetime import datetime, timedelta
import os.path
from pprint import pprint
import re
import sys
from icalendar import Calendar, Event, vDDDTypes
_metadata:
major_version: 1
minor_version: 1
display_information:
name: IMMP
features:
app_home:
home_tab_enabled: false
messages_tab_enabled: true
messages_tab_read_only_enabled: false
@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
@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 / 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 / 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 / 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 / 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`):