Skip to content

Instantly share code, notes, and snippets.

View jasonmadigan's full-sized avatar

Jason Madigan jasonmadigan

View GitHub Profile
@jasonmadigan
jasonmadigan / water_leak_action_blueprint.yaml
Last active November 19, 2024 15:38
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 / 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
/**
* 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;
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)
@jasonmadigan
jasonmadigan / narwhal_hyperweb.js
Created August 11, 2023 13:41
Narwhal Hyperweb
window.location.href = `narwhal://${window.location.host}${window.location.pathname}`;
@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 / 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;

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 / kup.sh
Last active December 9, 2024 16:32
kup.sh
#!/bin/bash
# Ref: https://github.com/Kuadrant/kuadrant-operator/blob/main/doc/user-guides/full-walkthrough/secure-protect-connect-openshift.md
export PREPEND="-jmtest1"
export KUADRANT_GATEWAY_NS=api-gateway$PREPEND # Namespace for the example Gateway
export KUADRANT_GATEWAY_NAME=external$PREPEND # Name for the example Gateway
export KUADRANT_DEVELOPER_NS=toystore$PREPEND # Namespace for an example toystore app
export KUADRANT_AWS_ACCESS_KEY_ID=$KUADRANT_AWS_ACCESS_KEY_ID # AWS Key ID with access to manage the DNS Zone ID below