Skip to content

Instantly share code, notes, and snippets.

@cas--
cas-- / tpm-reenroll.sh
Last active December 29, 2025 13:21
Ubuntu 24.04 TPM Re-enrollment
#!/bin/bash
set -e
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "This script must be run as root. Please use: sudo tpm-reenroll"
exit 1
fi
# CONFIGURATION - Change this to match what you used initially!
@cas--
cas-- / s3_tar_extract.py
Created April 3, 2025 14:36
Stream and extract S3 tar file
#! /usr/bin/env -S uv run
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "boto3",
# "click",
# "zstandard",
# ]
# ///
"""
@cas--
cas-- / test-xkb-keycodes.md
Last active November 17, 2024 11:26
Test XKB Keycodes

Test Event to XKB keycode mapping

This is a simple program using libxkbcommon to verify that input event keycodes are converted to XKB key symbols. Intended to be used to debug Kodi not mapping keycodes above 255.

Prerequisites

Required build tools and libraries.

@cas--
cas-- / .gitconfig
Created April 19, 2024 15:00
Common Git Aliases
[alias]
b = branch
br = branch
ci = commit
ci-aa = commit --am -a
ci-f = "!git commit --fixup=$1 $2 #"
ci-s = "!git commit --squash=$1 #"
co = checkout
cob = checkout -b
chp = cherry-pick
@cas--
cas-- / uk_bbox_example.py
Created December 21, 2023 14:23
Satellite data example
import pandas as pd
import requests
from shapely.geometry import box
start_date = "2022-06-01"
end_date = "2022-06-10"
data_collection = "SENTINEL-1"
# http://bboxfinder.com/#49.693397,-5.862579,50.839769,-4.107513
shapely_polygon = box(-5.862579, 49.693397, -4.107513, 50.839769)
@cas--
cas-- / gist:8e55d01a897500f836e010f0ad858f41
Created July 6, 2023 21:48
Vorta for Borg Exclude Patterns
# Exclude caches
**/.cache
**/cache
~/.thumbnails
**/.DS_Store
**/Thumbs.db
~/.wget-hsts
# Mounted file system
OFFSET = 127462 - ord('A')
def unicode_flag_to_country_code(code_points: list) -> str:
"""Converts unicode emoji flag to country code string
Args:
code_points: A list of unicode code points representing a
country flag
@cas--
cas-- / index.html
Created May 4, 2023 14:16
Text corruption on Linux Intel GPU
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'" />
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'" />
<link rel="stylesheet" href="styles.css">
<title>Linux Intel GPU rendering bug</title>

These steps will create a git alias command to parse a Jira issue reference from a branch and automatically append it to a commit message.

Create a Sureswift specific git config e.g. ~/sureswift/.gitconfig. The path will be the parent directory where you keep all the repositories e.g. ~/sureswift. Add your details and a 'jira' trailer for the Jira reference:

[user]
	name = Your Name
	email = your.name@sureswiftcapital.com
### Keybase proof
I hereby claim:
* I am cas-- on github.
* I am calumlind (https://keybase.io/calumlind) on keybase.
* I have a public key whose fingerprint is EA01 185D 0E8A A00D 6323 A308 9059 7A68 7B83 6BA3
To claim this, I am signing this object: