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 / 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 / IngressDualMap.user.js
Last active March 27, 2023 10:33
An IITC plugin that exports portals currently in view as a CSV list for use with Ingress Dual Map.
// ==UserScript==
// @id iitc-plugin-ingressdualmap-exporter@OllieTerrance
// @name IITC plugin: Ingress Dual Map Exporter
// @category Keys
// @version 0.0.0.1
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @description Exports portals currently in view as a CSV list for use with Ingress Dual Map.
// @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
@Terrance
Terrance / DataUsage.py
Last active June 7, 2021 05:29
Methods for parsing free mobile data usage on Three UK and FreedomPop UK. No guarantees that these will work with paid data plans.
from collections import namedtuple
from datetime import datetime, date, timedelta
import re
import requests
from bs4 import BeautifulSoup
Row = namedtuple("Row", ["number", "network", "total", "left", "reset"])
_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 / 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
@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

Keybase proof

I hereby claim:

  • I am Terrance on github.
  • I am terrance (https://keybase.io/terrance) on keybase.
  • I have a public key whose fingerprint is A78E 9C1E 9514 4560 7BF0 77C8 645A 86C9 6168 F957

To claim this, I am signing this object:

@Terrance
Terrance / monzo-oauth.html
Last active June 26, 2018 12:59
Alternative single-HTML-file Monzo login page, a drop-in replacement for https://auth.monzo.com.
<!DOCTYPE html>
<html>
<head>
<title>Monzo account access</title>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css"
integrity="sha256-zIG416V1ynj3Wgju/scU80KAEWOsO5rRLfVyRDuOv7Q="
crossorigin="anonymous">
<style>
@Terrance
Terrance / CacheResult.py
Created October 21, 2015 21:03
A Python decorator for caching a function result on first call (e.g. for network requests). Works well with the property decorator.
from functools import wraps
from inspect import getargspec
def cacheResult(fn):
cacheAttr = "{0}Cache".format(fn.__name__)
argSpec = getargspec(fn)
argNames = argSpec.args[1:]
if len(argNames) > 1:
raise RuntimeError("can't cache results if function takes multiple args")
argName = argNames[0] if len(argNames) else None
@Terrance
Terrance / SlackRTM.py
Last active June 20, 2018 18:44
A minimal asyncio client for the Slack real-time messaging (RTM) APIs.
import aiohttp
import asyncio
import logging
class SlackAPIError(Exception): pass
class Slack(object):
"""