Skip to content

Instantly share code, notes, and snippets.

View jasonmadigan's full-sized avatar

Jason Madigan jasonmadigan

View GitHub Profile

DCO

git commit templates only work with interactive message writing. Need a hook for -m commits.

Create a hook

cd .git/hooks
touch commit-msg
chmod +x commit-msg
@jasonmadigan
jasonmadigan / mongo_prune.js
Last active April 7, 2024 20:29
Unifi Client prune
// keep N-day worth of data
var days=7;
// change to false to have the script to really exclude old records
// from the database. While true, no change at all will be made to the DB
var dryrun=true;
var now = new Date().getTime(),
time_criteria = now - days * 86400 * 1000,
time_criteria_in_seconds = time_criteria / 1000;
@jasonmadigan
jasonmadigan / mgc-install-guide-base-setup.sh
Last active September 4, 2023 14:49 — forked from eoinfennessy/mgc-install-guide-base-setup.sh
Base setup for MGC install guide
#!/bin/bash
make local-setup-mgc
make local-setup-kind OCM_SINGLE=true
./bin/clusteradm init --bundle-version='0.11.0' --wait --context kind-mgc-control-plane
hub_token=$(./bin/clusteradm get token --context kind-mgc-control-plane -o=json | jq -r '."hub-token"')
hub_apiserver=$(./bin/clusteradm get token --context kind-mgc-control-plane -o=json | jq -r '."hub-apiserver"')
./bin/clusteradm join kind-mgc-control-plane --hub-token ${hub_token} --hub-apiserver ${hub_apiserver} --cluster-name kind-mgc-control-plane --bundle-version='0.11.0' --force-internal-endpoint-lookup --context kind-mgc-control-plane --feature-gates=RawFeedbackJsonString=true
@jasonmadigan
jasonmadigan / narwhal_hyperweb.js
Created August 11, 2023 13:41
Narwhal Hyperweb
window.location.href = `narwhal://${window.location.host}${window.location.pathname}`;
import requests
from geopy.distance import geodesic
from geopy.geocoders import Nominatim
def get_outages():
url = "https://api.esb.ie/esbn/powercheck/v1.0/outages"
headers = {"api-subscription-key": "f713e48af3a746bbb1b110ab69113960"}
response = requests.get(url, headers=headers)
/**
* Monitor an MQTT connection, and HTTP connectivity to Home Assistant
* if either fail - trigger a fail-safe mode which turns the switch on.
*
*/
// Config
let homeAssistantUrl = "https://x.x.x.x:8123";
// number of times the check is done before internet is considered as down.
let maxfails = 2;
@jasonmadigan
jasonmadigan / oil_tank.yaml
Last active November 10, 2022 09:38
Home Assistant sensor(s) for Kingspan Watchman SENSiT Oil Tank monitor
# Sensor(s) for Kingspan Watchman SENSiT Oil Tank monitor: https://www.kingspan.com/ie/en/products/tank-monitoring-systems/remote-tank-monitoring/watchman-sensit/
# Replace email & password in the payload
- platform: rest
name: Oil Tank
resource: https://www.connectsensor.com/soap/MobileApp.asmx
method: POST
payload: '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><SoapMobileAPPAuthenicate_v3 xmlns="http://mobileapp/"><emailaddress>[email protected]</emailaddress><password>_PASSWORD_</password></SoapMobileAPPAuthenicate_v3></soap:Body></soap:Envelope>'
headers:
Content-Type: text/xml
@jasonmadigan
jasonmadigan / water_leak_action_blueprint.yaml
Last active November 13, 2024 20:31
HASS Water Leak Alert Blueprint
blueprint:
name: Moisture Sensor
description: Perform action when moisture sensor turns wet
domain: automation
input:
actions:
name: Actions
description:
Notifications or similar to be run. {{ trigger.event.data.new_state.attributes.friendly_name
}} will be the name of the sensor
@jasonmadigan
jasonmadigan / frigate_test_clip.md
Last active March 13, 2024 19:36
Frigate Test Camera

Frigate Test Clip

To tune Frigate, it can sometimes be useful to input saved clips in order to see how detection works. I've found the easiest way to accomplish this is by grabbing a clip (say, from your NVR), and streaming this on a loop via RTSP to Frigate. This will let you tune settings with an existing configuration, which is a bit different to using process_clip.py that's included with Frigate.

Pre-requisites

  • A sample clip, in a format supported by ffmpeg (.mp4 is good)
  • Docker on a machine that'll do the streaming
  • A working ffmpeg install. I'm using a mac, so I typically install via Brew: brew install ffmpeg