Skip to content

Instantly share code, notes, and snippets.

View wolph's full-sized avatar

Rick van Hattem wolph

View GitHub Profile
@wolph
wolph / _toastr.md
Last active April 30, 2025 11:20
Enhanced Toastr Notification Library

Enhanced Toastr Notification Library

Version: 2.1.4
Built for modern web applications with extended notification API functionality.


Overview

The Enhanced Toastr Notification Library is a lightweight, flexible, and developer-friendly solution for displaying notifications in your web applications. Building on the legacy of Toastr.js, this modified version returns a rich notification API object with methods for dynamic updates and programmatic control. The library adheres to modern JavaScript best practices, supporting asynchronous operations, streamlined debugging, and modular configuration.

GMStorage – Advanced Storage Utility for Userscripts

The GMStorage class is an advanced wrapper for Greasemonkey, Tampermonkey, or Violentmonkey storage APIs. It streamlines persistent data management by offering a natural JavaScript object interface with built-in synchronization across tabs, deep object update detection, and robust merging of default values.

Key Features:

  • Natural Read/Write Operations:
    Access and update storage keys as if they were object properties.

  • Deep Proxying for Nested Updates:

@wolph
wolph / split_nginx_logs.py
Created March 11, 2025 08:35
Script to split (large) existing nginx logs per year/month with colourful verbose output and progressbars.
#!/usr/bin/env python3
"""
Script to split existing nginx logs per year/month with verbose output.
This script accepts a configurable directory (defaulting to the current working
directory) of nginx logs. It looks for files named <domain>.access_log and
<domain>.error_log. Each log line is expected to contain a timestamp inside
square brackets, e.g., [10/Oct/2000:13:55:36 -0700]. The script extracts the
date and writes each line into a separate file under a subdirectory formatted
as YYYY-MM.
@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 April 25, 2025 18:13
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