Skip to content

Instantly share code, notes, and snippets.

@jwhb
jwhb / docker-volume-size.sh
Created February 3, 2024 11:15
Sort Docker volumes by size
#!/bin/sh
docker system df -v --format json | jq -r '.Volumes[] | [.Size,.Name] | @tsv' | sort -h
@jwhb
jwhb / gitlab-export.py
Last active October 31, 2023 20:27
Create export of all GitLab user project.
# GitLab user project export
#
# Install gitlab module: python3 -m pip install python-gitlab==3.15.0
#
# Set environment variables GITLAB_URL and GITLAB_OAUTH_TOKEN (Personal Access Token):
# GITLAB_URL=https://gitlab.com GITLAB_OAUTH_TOKEN=changeme python3 gitlab-export.py
import gitlab
import time
import tarfile
@jwhb
jwhb / WXKG02LM_rev2.yaml
Last active April 7, 2023 18:10 — forked from Stayer/WXKG02LM.yaml
Zigbee2MQTT, SLS - Aqara Wall Wireless Switch Double Key Edition (WXKG02LM_rev2)
blueprint:
name: v2 Zigbee2MQTT, SLS - Aqara Wall Wireless Switch Double Key Edition (WXKG02LM_rev2)
actions
description: 'Define actions your Aqara Wall Wireless Switch Double Key Edition
using Zigbee2MQTT or SLS. For your button entity, choose the right sensor with
your button name and the entity id which ends with ''_action'', e.g. ''sensor.kitchen.button_action''
'
domain: automation
input:
@jwhb
jwhb / zigbee2mqtt-ikea-e1524-e1810-tradfri-remote-control.yaml
Last active April 1, 2024 05:38
IKEA E1524 Tradfri Remote Control - Home Assistant Blueprint
blueprint:
name: Zigbee2MQTT - IKEA E1524/E1810 Tradfri Remote Control
description: Control anything using "IKEA E1524/E1810 Tradfri Remote Control"
domain: automation
input:
action_sensor:
name: Remote
description: Zigbee2MQTT action sensor
selector:
entity:
@jwhb
jwhb / gist:de4225afba72328af443671177666ec5
Created January 31, 2023 10:24
python3 HTTP inspection
#!/usr/bin/python3
import http.server
import socketserver
import logging
PORT=8000
class ServerHandler(http.server.SimpleHTTPRequestHandler):
@jwhb
jwhb / route_backup.ps1
Created April 11, 2022 09:49
Windows Route Backup (useful for Windows Container usage like RKE2 where HNS configuration wipes the routes)
# Route Backup
#
# Creates a script at C:\eth_routes.ps1 (or user Desktop) with `route add` statements to re-apply routing table entries of a specific interface.
#
# Useful for Windows Container usage like RKE and RKE2 Kubernetes, where HNS configuration wipes parts of the routing table.
# Related issue: https://projectcalico.docs.tigera.io/getting-started/windows-calico/troubleshoot#after-initializing-calico-for-windows-aws-metadata-server-is-no-longer-reachable
$ifname = "Ethernet"
$default_metric = 5
@jwhb
jwhb / podman.yml
Last active February 1, 2022 12:34
Rootful Podman on RockyLinux for lima-vm
# Example to use Podman instead of containerd & nerdctl
# $ limactl start ./podman.yaml
# $ limactl shell podman podman run -it -v $HOME:$HOME --rm docker.io/library/alpine
# To run `podman` on the host (assumes podman-remote is installed):
# $ export CONTAINER_HOST=$(limactl list podman --format 'unix://{{.Dir}}/sock/podman.sock')
# $ podman --remote ...
# To run `docker` on the host (assumes docker-cli is installed):
# $ export DOCKER_HOST=$(limactl list podman --format 'unix://{{.Dir}}/sock/podman.sock')
@jwhb
jwhb / extract_sa_token.sh
Last active November 24, 2021 14:56
kubectl: extract serviceaccount token
#!/bin/sh
NAMESPACE=default
SERVICE_ACCOUNT=mysa
# kubectl -n $NAMESPACE create sa $SERVICE_ACCOUNT
kubectl -n $NAMESPACE get secret `kubectl -n $NAMESPACE get serviceaccount $SERVICE_ACCOUNT -ojsonpath="{.secrets[0].name}"` -ojsonpath="{.data.token}" | base64 -d
# BONUS: use kubectl with the service account token:
kubectl --token="${TOKEN}" -s https://api.<cluster-domain>:6443 --insecure-skip-tls-verify=true get pod
@jwhb
jwhb / wait.yaml
Created November 25, 2020 10:35
Ansible: Wait for OpenShift Cluster to be installed
---
- name: Wait for OpenShift Cluster to be installed
hosts: localhost
tasks:
- name: Wait for Cluster to be installed
k8s_info:
api_version: config.openshift.io/v1
kind: ClusterVersion
name: version
register: ocp_clusterversion_result
@jwhb
jwhb / .bashrc
Created July 26, 2020 17:07
WSL: init gpg-agent in Bash
export GPG_TTY=$(tty)
pgrep -U $UID gpg-agent > /dev/null || gpg-connect-agent /bye > /dev/null 2>&1