Skip to content

Instantly share code, notes, and snippets.

View wolph's full-sized avatar

Rick van Hattem wolph

View GitHub Profile
@wolph
wolph / auto_pyright_ruff_llm_code_improver.py
Last active January 15, 2025 06:09
Automatically improve code quality by having an LLM fix ruff/pyright/mypy errors and by having it refactor code. GPT-o1 or stronger models recommended.
#!/usr/bin/env python3
import argparse
import ast
import asyncio
import difflib
import logging
import os
import pathlib
import re
@wolph
wolph / tox_ini_to_toml.py
Last active January 2, 2025 01:59
Convert a tox.ini to tox.toml or pyproject.toml file.
#!/usr/bin/env python3
import argparse
import configparser
import os
import re
import shlex
import sys
from typing import Any
@wolph
wolph / autoexec.be
Created November 2, 2024 12:41
Sonoff TX Ultimate Berry driver including sound and buzzer effects for Tasmota and automatic relay detection
import string
import persist
var PERSIST_VERSION = 2
var PIXEL_COUNT = 28
var BUTTON_COUNT = size(tasmota.get_power()) - 1
var LEDS = {
2: {
0: [11, 20],
@wolph
wolph / ah.user.js
Last active February 26, 2025 00:13
Albert Heijn AH.nl kortingspercentage en prijs per kg script
// ==UserScript==
// @name Albert Heijn Korting Updated (with Promotion Parsing)
// @namespace https://wol.ph/
// @version 1.0.6
// @description Add price per unit and discount percentage to products and promotion cards (updated for new page structures)
// @author wolph
// @match https://www.ah.nl/*
// @icon https://icons.duckduckgo.com/ip2/ah.nl.ico
// @grant none
// @license BSD
@wolph
wolph / backfill_mindergas.py
Created January 9, 2024 02:46
Upload historical data from InfluxDB to mindergas.nl
'''
Use an influxdb query like this to fetch the data and store it as `meterstanden.csv`:
```
SELECT max("value") FROM "m3" WHERE ("entity_id"::tag = 'gas_consumption') AND $timeFilter GROUP BY time(1d) fill(linear)
```
'''
import pandas as pd
import json
import requests
import progressbar
@wolph
wolph / pretty-pyright
Last active June 25, 2023 21:35
Little python script to wrap around pyright to add indenting, reformatting and making it easier to read. It also adds pretty colours
#!/usr/bin/env python -u
import os
import re
import sys
import itertools
import contextlib
import subprocess
sys.stdout.reconfigure(line_buffering=True)
@wolph
wolph / lights.yaml
Last active November 18, 2024 18:06
ESPHome Sonoff TX Ultimate T5-3C-86 Custom button component
light:
- platform: neopixelbus
type: GRB
variant: WS2812
pin: GPIO1
num_leds: 1
name: "NeoPixel 1"
internal: true
- platform: neopixelbus
type: GRB
// ==UserScript==
// @name nzbking size and extension filtering
// @namespace http://wol.ph/
// @version 0.1
// @description Automatically hides downloads that are too small or only contain extensions such as exe, jpg, nfo, etc...
// @author wolph
// @match https://www.nzbking.com/*
// @icon https://icons.duckduckgo.com/ip2/nzbking.com.ico
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js
// @grant none
@wolph
wolph / benchmark_attribute_access.py
Last active May 10, 2024 13:02
Benchmark namedtuple vs dataclass vs dict
import sys
import enum
import math
import random
import timeit
import typing
import dataclasses
import collections
@wolph
wolph / google-cookie-consent.user.js
Last active February 4, 2025 11:31
Google Cookie Consent Remover