Skip to content

Instantly share code, notes, and snippets.

@ahue
ahue / trace script.cover_open_close_duplicate 2025-01-05T10_55_51.170362+00_00.json
Created January 5, 2025 11:02
trace script.cover_open_close_duplicate 2025-01-05T10_55_51.170362+00_00
{
"trace": {
"last_step": "sequence/0",
"run_id": "7ed63d28d91f10de3817de1695fb27e1",
"state": "stopped",
"script_execution": "error",
"timestamp": {
"start": "2025-01-05T10:55:51.170362+00:00",
"finish": "2025-01-05T10:55:51.173932+00:00"
},
@ahue
ahue / ha-shelly-plus1-button-actions.yaml
Last active October 24, 2024 05:05
Home Assistant Shelly Plus 1 Button Actions Blueprint
blueprint:
name: Shelly Plus 1 Button actions
description: |
This blueprint is for the Shelly PLus 1 setup as button. It is for general
use.
Note: Best set the `Input/Output settings` to `Detached - Input is separated/not changing state of the output/relay` on the Shelly: `http:/<shelly-ip>/#/input/0/settings/io-settings`.
In case you still want to control the primary output directly from the Shelly, create a local action: `http:/<shelly-ip>/#/input/0/create-action`.
domain: automation
input:
@ahue
ahue / license-plate-regex.md
Created April 22, 2022 12:02
License Plate Regex

Only guarantees structural compliance to definition

Germany

[A-ZÄÜÖ]{2,3}[ -][A-ZÄÜÖ]{1,2}[ -]\d{1,4}

Source

@ahue
ahue / obsidian.sh
Created April 10, 2022 12:49
Obsidian pull-push script for Android
#!/data/data/com.termux/files/usr/bin/bash
cd ~/storage/shared/documents/my-vault
git add --all
git commit -m "mobile update $(date)"
git pull --rebase
git push origin main
@ahue
ahue / fix-docker-machine-time-sync.ps1
Created March 29, 2022 20:18
fix-docker-machine-time-sync.ps1
$vm = Get-VM -Name DockerDesktopVM
$feature = "Zeitsynchronisierung"
Disable-VMIntegrationService -vm $vm -Name $feature
Enable-VMIntegrationService -vm $vm -Name $feature
cd ~/storage/shared/documents/my-vault
git pull --rebase
git add --all
git commit -m "mobile update $(date)"
git push origin main
@ahue
ahue / zh_sync.sh
Last active January 5, 2022 20:33
obsidian sync script
#!/data/data/com.termux/files/usr/bin/bash
# ^^^^^^^^^^^^^^^ This says find the first instance of a sh (shell)
# binary and use that shell to execute these commands.
# There is little to no complexity here and no bashisms so it
# should work just fine on most systems and instances of shells
# (bash, zsh, sh, etc.)
# original from: https://gist.githubusercontent.com/lucidhacker/0d6ea6308997921a5f810be10a48a498/raw/386fd5c640282daeaa3c9c5b7f4e875511c2946c/zk_sync.sh
# modified according to: https://lucidhacker.substack.com/p/setting-up-git-syncing-for-obsidian
@ahue
ahue / cluster_corr.py
Last active May 4, 2021 08:40
Rearranges the correlation matrix, corr_array, so that groups of highly correlated variables are next to eachother
import scipy
import scipy.cluster.hierarchy as sch
def cluster_corr(corr_array, inplace=False, impute_nan=False):
"""
Original author: @WYegelwel (https://wil.yegelwel.com/cluster-correlation-matrix/)
Rearranges the correlation matrix, corr_array, so that groups of highly
correlated variables are next to eachother
@ahue
ahue / cardinalities.py
Created May 3, 2021 11:52
Analyize cardinalities of a pandas Data.Frame
import pandas as pd
import seaborn as sns
def cardinalities(df: pd.DataFrame, plot: bool = False):
"""
Analyses cardinalities in a data frame
df DataFrame the data frame to be analyized
plot Plot whether to plot rather than return the result DataFrame
returns (DataFrame, Plot) of a matrix M(i,j) that reads row-wise,
@ahue
ahue / gist:98eb5a7744c24bb2b2b358985acefdc4
Created April 14, 2021 20:58
Filter a 3d array on one dimension using and 2d index to receive a 2d array
import numpy as np
def filter_tensor_by_mx(tensor, mx):
tshape = tensor.shape
row_ix = np.arange(mx.shape[0])
col_ix = np.arange(mx.shape[1])
ix = np.array(np.meshgrid(row_ix, col_ix)).T.reshape(-1,2).T
pane = rnd_ix_mx.ravel()
res = tensor[pane, ix[0], ix[1]].reshape(mx.shape)
return res