Skip to content

Instantly share code, notes, and snippets.

@leighklotz
leighklotz / logging.sh
Last active April 3, 2025 21:23
Bash Logging
#!/bin/bash
# Check if the script is being sourced or directly executed
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
echo "This script is intended to be sourced, not executed directly." >> /dev/stderr
exit 1
fi
COLOR_RED='\e[1;31m'
COLOR_YELLOW='\e[1;33m'
@leighklotz
leighklotz / extract-bbox.py
Created March 29, 2025 05:45
Extract tiles from a Zip of OSM tiles, for Meshastic, APRS, etc.
#!/usr/bin/env python3
# $ ./extract-bbox.py --zipfile OxedOSM_USA_0-13.zip --depth 13 --center-lat 37.123456 --center-lon -122.876543 --radius 10
import os
import zipfile
import argparse
from math import floor, pi, tan, cos, log
@leighklotz
leighklotz / dmesg.txt
Created January 26, 2024 20:23
RPI5 X1002 MP32 failures
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x414fd0b1]
[ 0.000000] Linux version 6.1.0-rpi7-rpi-2712 ([email protected]) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24)
[ 0.000000] random: crng init done
[ 0.000000] Machine model: Raspberry Pi 5 Model B Rev 1.0
[ 0.000000] efi: UEFI not found.
[ 0.000000] Reserved memory: created CMA memory pool at 0x0000000018000000, size 320 MiB
[ 0.000000] OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool
[ 0.000000] Zone ranges:
[ 0.000000] DMA [mem 0x0000000000000000-0x00000000ffffffff]
[ 0.000000] DMA32 empty
@leighklotz
leighklotz / dmesg.txt
Created January 26, 2024 19:53
RPI5 X1002 MP32 failures
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x414fd0b1]
[ 0.000000] Linux version 6.1.0-rpi7-rpi-2712 ([email protected]) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24)
[ 0.000000] random: crng init done
[ 0.000000] Machine model: Raspberry Pi 5 Model B Rev 1.0
[ 0.000000] efi: UEFI not found.
[ 0.000000] Reserved memory: created CMA memory pool at 0x0000000018000000, size 320 MiB
[ 0.000000] OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool
[ 0.000000] Zone ranges:
[ 0.000000] DMA [mem 0x0000000000000000-0x00000000ffffffff]
[ 0.000000] DMA32 empty
@leighklotz
leighklotz / openworld.txt
Created January 20, 2024 00:15
Open World Prompt
The AI considers the possibility of new information and knowledge that may not have been encountered during training, in accordance with the Open World Hypothesis.
@leighklotz
leighklotz / list-branches.sh
Created September 27, 2023 16:46
list-branches.sh
#!/bin/bash
for branch in $(git branch | sed -e 's/[*]//')
do
echo -ne "${branch}\tis contained in these branches:\t"
git branch --contains "${branch}" | tr '\n*' ' ' | sed -e "s/\<${branch}\>//"
echo
done
In Terraform, there is no built-in function to deeply merge two maps. However, you can achieve this by combining multiple functions and applying some custom logic. Here's an example of how you can deeply merge two maps in Terraform:
```hcl
locals {
map1 = {
key1 = "value1"
key2 = {
nested_key1 = "nested_value1"
}
key3 = {
export PATH="/usr/local/cuda-11.7/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-11.7/lib64:$LD_LIBRARY_PATH"
# ldconfig
klotz@tensor:~$
@leighklotz
leighklotz / main.c
Created April 10, 2023 01:30
Codex Prompt was main function (interactively written) and first two comment lines; it generated the assembly
#include "main.h"
int main(int argc, char *argv[])
{
printf("Hello World: %d", argc);
for (int i = 0; i < argc; i++)
{
printf("%s", argv[i]);
}
return 0;