Skip to content

Instantly share code, notes, and snippets.

View rnorth's full-sized avatar

Richard North rnorth

View GitHub Profile
@rnorth
rnorth / update_device_areas.py
Last active April 12, 2024 20:11
Home Assistant pyscript to mass-update device areas
import homeassistant
@service
def update_device_areas():
devreg = homeassistant.helpers.device_registry.async_get(hass)
entreg = homeassistant.helpers.entity_registry.async_get(hass)
areareg = homeassistant.helpers.area_registry.async_get(hass)
area_ids = []
#
# Python
#
export PYENV_ROOT=${PYENV_ROOT:-$HOME/.pyenv}
# Usage:
# Add to .envrc file:
# use python 3.7.5
use_python() {
# Install pyenv for management of Python versions
@rnorth
rnorth / gist:2031652
Created March 13, 2012 21:14
Cookie-based authentication with nginx
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
@rnorth
rnorth / agenda
Last active January 17, 2022 06:56
agenda: exports today's calendar entries from Mac Calendar.app into a markdown file to enable note-taking
#!/usr/bin/swift
//
// agenda: exports today's calendar entries from Mac Calendar.app into a markdown file to enable note-taking
//
// Example usage:
// agenda > agenda-$(date +%Y-%m-%d).md
//
import EventKit
#!/bin/bash
set -euo pipefail
COMBINED_BRANCH=combined-pr-branch
BODY_FILE=/tmp/.combined-pr-body.md
LIMIT=50
echo -n > $BODY_FILE
@rnorth
rnorth / gh-notification-cleaner
Created June 17, 2021 12:51
Script to clean up GitHub notifications by marking all notifications for merged/closed Dependabot PR as read
#!/bin/bash
gh api notifications --paginate --jq '.[] | [.subject.url,.url] | @tsv' | while read -r URL THREAD_URL; do
ITEM=$(gh api $URL)
NUMBER=$(jq -r .number <<< ${ITEM})
TITLE=$(jq -r .title <<< ${ITEM})
STATE=$(jq -r .state <<< ${ITEM})
echo "$NUMBER $TITLE $STATE"
@rnorth
rnorth / tips.md
Created March 13, 2020 16:12
Machine Relevance Show and Tell - staying sane and being effective while working from home
richardnorth@mbp ~/g/t/testcontainers-java> while true
./gradlew couchbase:clean couchbase:test --tests "org.testcontainers.couchbase.*" -i --no-build-cache | tee /dev/fd/2 | tail -n10 | ~/personalbin/nfy
sleep 1; clear
end
Initialized native services in: /Users/richardnorth/.gradle/native
Found daemon DaemonInfo{pid=56918, address=[00bfe441-56b5-4f8f-9ce6-0b7dd6e736f1 port:59163, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]], state=Idle, lastBusy=1573844859729, context=DefaultDaemonContext[uid=cbb29f0d-797d-4a3a-bc17-fc477d02c3a9,javaHome=/Users/richardnorth/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/193.5096.12/IntelliJ IDEA 2019.3 EAP.app/Contents/jbr/Contents/Home,daemonRegistryDir=/Users/richardnorth/.gradle/daemon,pid=56918,idleTimeout=10800000,priority=NORMAL,daemonOpts=-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-agentlib:jdwp=transpo
@rnorth
rnorth / keybase.md
Last active November 9, 2019 09:48
keybase.md

Keybase proof

I hereby claim:

  • I am rnorth on github.
  • I am richnorth (https://keybase.io/richnorth) on keybase.
  • I have a public key whose fingerprint is EBEE 5EE7 3820 918C F7F9 D867 EDF4 C124 5923 343E

To claim this, I am signing this object:

import com.github.dockerjava.api.command.InspectContainerResponse;
import eu.rekawek.toxiproxy.Proxy;
import eu.rekawek.toxiproxy.ToxiproxyClient;
import eu.rekawek.toxiproxy.model.ToxicDirection;
import eu.rekawek.toxiproxy.model.ToxicList;
import org.junit.Rule;
import org.junit.Test;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;