Skip to content

Instantly share code, notes, and snippets.

@jayme-github
jayme-github / gist:a8d533300e5313e18725d9cc89bd26e8
Created February 17, 2023 11:47
Figure out the keypair used to sign a kubernetes service account token
# Get namespace, secret name and JWT "kid" (key ID) of all service-account-token secrets
kubectl get secrets --field-selector type=kubernetes.io/service-account-token \
-o jsonpath='{range .items[*]}{.data.token}{"\n"}{end}' -A |
while read token; do
echo $token | base64 -d | step crypto jwt inspect --insecure | jq -r '[ .payload."kubernetes.io/serviceaccount/namespace", .payload."kubernetes.io/serviceaccount/secret.name", .header.kid] | @tsv'
done
# The key ID references the public-key that needs to be used to validate the signature.
# Compute the kid for a given public-key like:
#!/bin/env python3
#
# Download LAADS data from https://ladsweb.modaps.eosdis.nasa.gov
#
import argparse
import concurrent.futures
import datetime
import shutil
@jayme-github
jayme-github / disable_raydium_touchscreen_thinkpad_x1_carbon_7th.md
Created March 28, 2020 11:37
Disable Raydium Touch System touchscreen on ThinkPad X1 Carbon 7th gen

To make the usbhid driver ignore the touchscreen device, add a HID_QUIRK_IGNORE quirk as module paramater:

Add a modprobe file, like /etc/modprobe.d/disable_raydium_touchscreen.conf:

# Add/modify USB HID quirks by specifying
# quirks=vendorID:productID:quirks where vendorID, productID, and quirks are all in 0x-prefixed hex
#
# For a list of quirks, see https://github.com/torvalds/linux/blob/master/include/linux/hid.h
options usbhid quirks=0x2386:0x4328:0x00000004
@jayme-github
jayme-github / gist:1f22326fba03ea365e223bd1f7c184c7
Last active February 4, 2020 16:20
LibreOffice/Excel handle dates different than you might think...
import math
import datetime
secs_per_day = 24 * 60 * 60
def SOMECALCFUNC(datefloat):
# date comes as float from libreoffice where the integer part is the number
# of days since 1899-12-30 and the decimal part is the time as fraction of
# day.
timefrac, days = math.modf(datefloat)
@jayme-github
jayme-github / k-list-empty-ns.sh
Created November 14, 2019 10:27
List all empty namespaces
#!/bin/bash
# grep -E pattern to ignore certain resources
IGNORE="^resourcequota/gke-resource-quotas|^secret/default-toke|^serviceaccount/default"
# Get a list of all "listable" namespaced ressources
resources=$(kubectl api-resources --verbs=list --namespaced=true -o name | paste -sd, -)
namespaces=$(kubectl get namespaces -o jsonpath='{.items[*].metadata.name}')
for ns in $namespaces; do
@jayme-github
jayme-github / helm_required_envs_hack.md
Last active February 27, 2019 13:11
Little hack to have a generic map of environment variables in a Helm chart but still require some of them to be set during install/update

values.yaml

## One may define arbitrary environment variables here
env:
  VARIABLE_ONE: "Foo"
  VARIABLE_TWO: ""

## List of all environment variables that are required by this helm chart
requiredEnvs:
  - VARIABLE_ONE

Installing Debian on btrfs subvolume

Install debian as usual:

  • EFI partition ~256M, boot, esp flags
  • ext2 boot partition ~512M
  • luks cyrpt volume
    • LVM pv
      • swap ~5G
      • btrfs

When the installation is finished, boot into SystemRescueCD.

@jayme-github
jayme-github / resize-slack-icon-kde.sh
Created February 6, 2019 11:12
Resize the default Slack notification icons
#!/bin/bash
# Slack default icons seem to big for KDEs taskbar (64x64px, don't know why KDE does not scale them down automatically).
# To fix that (being able to see notification bubbles again!), simply resize the icons.
# For me 24x24px is optimal.
sudo mogrify -resize 24x24 /usr/lib/slack/resources/app.asar.unpacked/src/static/slack-taskbar-*.png
#!/usr/bin/env bash
set -x
NS="ns1"
VETH="veth1"
VPEER="vpeer1"
VETH_ADDR="10.200.1.1"
VPEER_ADDR="10.200.1.2"
@jayme-github
jayme-github / clouddns-dump.sh
Last active September 13, 2018 07:40
dump all google clouddns zones
gcloud dns managed-zones list --uri | parallel gcloud dns record-sets export -z "{}" --zone-file-format "{/}.zone"