Skip to content

Instantly share code, notes, and snippets.

View thehesiod's full-sized avatar
🎯
Focusing

Alexander Mohr thehesiod

🎯
Focusing
View GitHub Profile
@thehesiod
thehesiod / rheem_usage.py
Last active January 20, 2023 22:01
Rheem Water Heater Energy Usage Calculator
import asyncio
import argparse
from collections import defaultdict
from datetime import date, timedelta
import logging
from typing import Dict
from pprint import pprint
from pyeconet import EcoNetApiInterface
from pyeconet.equipment import EquipmentType
@thehesiod
thehesiod / watchdog.py
Created May 19, 2022 15:28
python sync watchdog
import asyncio
import faulthandler
import warnings
from pathlib import Path
import io
from typing import Optional
# This is how often we'll trigger our callback to measure blockage
_MIN_RESOLUTION = 0.1
@thehesiod
thehesiod / file_sync.py
Created May 12, 2022 02:16
async file syncer
import asyncio
import os
from pathlib import Path
from typing import Dict, Optional
import logging
import shutil
from functools import partial
import hashlib
import dataclasses
@thehesiod
thehesiod / android_dcim_cleanup.py
Last active December 6, 2020 20:06
Delete Empty Android DCIM folders
# requires webdav connection (see WebDAV Server app, and ensure port is not 8080)
from pathlib import Path
import shutil
def main():
cam_path = Path('//192.168.1.186@8081/DavWWWRoot/DCIM/Camera')
for idx, item in enumerate(cam_path.iterdir()):
if idx % 100 == 0:
print(f"Processing folder {idx}")
@thehesiod
thehesiod / freeze_time.sql
Created May 20, 2020 09:41
fake/mock now on postgres DB
-- inspiration from https://dba.stackexchange.com/questions/69988/how-can-i-fake-inet-client-addr-for-unit-tests-in-postgresql/70009#70009
CREATE SCHEMA if not exists override;
create table if not exists override.freeze_time_param_type
(
param_type text not null primary key
);
insert into override.freeze_time_param_type values ('enabled'), ('timestamp'), ('tick') on conflict do nothing;
import asyncio
import os
import time
import logging
from multiprocessing import Process, Queue
from queue import Empty
import botocore.session
from botocore.credentials import Credentials, CredentialResolver, CredentialProvider, AssumeRoleProvider
@thehesiod
thehesiod / audi_manual_downloader.py
Created August 5, 2019 06:57
Audi Manual Downloader
import requests
import shutil
def download_manual():
# three digit page number
code = 'aa99bbcc-110b-999a-9a11-bb99b9aa1d99' # example, will not work
url = "https://webcat.lex-com.net/AudiBordbuch/docs/{code}/files/assets/common/page-html5-substrates/page0{page_num:03d}_4.jpg?uni=c91d23879402ccf1e95bc4acbec392e4"
# low rez
@thehesiod
thehesiod / netcdf_mem_file_test.py
Created December 21, 2018 02:30
netCDF Processing Error test
import requests
import netCDF4
import gzip
import tempfile
import traceback
import os.path
import glob
def test_cdf_bytes(cdf_compressed_bytes: bytes):
@thehesiod
thehesiod / calendar_bug.py
Last active October 10, 2018 06:05
Google Calendar bug with recurring events
from googleapiclient import discovery
import httplib2
from oauth2client.service_account import ServiceAccountCredentials
calendar_id = '[email protected]'
resource_calendar_id = '[email protected]'
def get_delegated_endpoint(base_creds: ServiceAccountCredentials, user_email: str):
creds = base_creds.create_delegated(user_email)
http = httplib2.Http(timeout=15)
@thehesiod
thehesiod / 1pass_dups.py
Last active September 16, 2024 19:46
1password duplicate remover (alpha, only run in debugger with breakpoints everywhere *g*)
#!/usr/bin/env python3
import json
import subprocess
import sys
from concurrent.futures import ThreadPoolExecutor
import html
import dictdiffer
import iso8601