Skip to content

Instantly share code, notes, and snippets.

@thebmw
thebmw / scrubhelper.py
Created July 18, 2023 00:00
scrubhelper
from typing import Callable
def inner_scrub(path: list[str], data: any, generator: Callable[[], str]):
this = data
for idx, x in enumerate(path):
if idx == len(path) - 1:
this[x] = generator()
if x.endswith('[]'):
for y in this[x[:-2]]:
inner_scrub(path[idx+1:], y, generator)
@thebmw
thebmw / sqlalchemy_replica.py
Created June 29, 2023 06:34 — forked from jasonwalkeryung/sqlalchemy_replica.py
SQLAlchemy read replica wrapper
"""This is not the full code. We do a lot of stuff to clean up connections, particularly for unit testing."""
import sqlalchemy
from sqlalchemy.orm import Query, Session, scoped_session, sessionmaker
CONFIG_KEY_SQLALCHEMY_BINDS = 'SQLALCHEMY_BINDS'
CONFIG_KEY_SQLALCHEMY_RO_BINDS = 'SQLALCHEMY_READ_ONLY_BINDS'
class Config:
# These default values are for testing. In a deployed environment, they would be three separate instances.
SQLALCHEMY_DATABASE_URI = 'postgresql://localhost/branded_dev'
@thebmw
thebmw / ge_zw.yaml
Last active January 16, 2023 21:54
GE Home Assistant Blueprint
blueprint:
name: GE Switch (Z-Wave JS) v0.03
description: Create automations for the GE Switches using the Z-Wave JS integration.
domain: automation
input:
ge_jasco:
name: Switch Device
description: List of available GE switches
selector:
device:
@thebmw
thebmw / ge_double.yaml
Last active January 16, 2023 21:31 — forked from kpine/ge_double.yaml
GE/Enbrighten Double Tap Generic Blueprint
blueprint:
name: GE Switch Double Taps
description: Create automations to react to double taps from supporting GE switches.
domain: automation
input:
device:
name: Switch Device
description: A GE switch that supports double taps.
selector:
@thebmw
thebmw / ge_zw4008.yaml
Last active January 16, 2023 21:33 — forked from shannonfritz/ge_zw4008.yaml
GE/Enbrighten Home Assistant Blueprint
blueprint:
name: GE/Enbrighten Switch (Z-Wave JS) v0.03
description: Create automations for the GE/Enbrighten Switches using the Z-Wave JS integration.
domain: automation
input:
ge_jasco:
name: Switch Device
description: List of available GE/Enbrighten switches
selector:
device:

Keybase proof

I hereby claim:

  • I am thebmw on github.
  • I am thebmw (https://keybase.io/thebmw) on keybase.
  • I have a public key ASAblYqiWnw6OEGAAaxRNAqGH-r1zjDxxlkWtljjL7OhFwo

To claim this, I am signing this object: