Skip to content

Instantly share code, notes, and snippets.

@Frank-Buss
Frank-Buss / similar-image.py
Created May 4, 2025 20:28
applies recursively the same prompt for editing an image and then creates a mp4 video of it
#!/usr/bin/env python3
import os
import time
import argparse
import shutil
import requests
import subprocess
import io
import traceback
@Frank-Buss
Frank-Buss / tabletest.lua
Last active May 1, 2025 17:34
redefine pairs for all tables
local original_next = next
local original_pairs = pairs
local function sorted_next(t, k)
local keys = {}
for key in original_pairs(t) do
table.insert(keys, key)
end
table.sort(keys)
# run like this:
# julia -O3 --check-bounds=no tm.jl busy-beaver-5.json --fast
using ArgParse
using JSON
# ANSI codes for inverse video and reset
const INVERSE = "\u001B[7m"
const RESET = "\u001B[0m"
function parse_commandline()
@Frank-Buss
Frank-Buss / readme.md
Created January 24, 2025 00:06
detecting buffer overflow and other memory problems in Zephyr programs

First add this to your CMakeLists.txt file:

if(BOARD STREQUAL "native_posix_64")
  target_compile_options(app PRIVATE -fsanitize=address -fsanitize=undefined)
  target_link_options(app PRIVATE -fsanitize=address -fsanitize=undefined)
  target_link_libraries(app PRIVATE asan ubsan)
endif()

For testing I used the blinky example, and added this at the beginning of the main function:

@Frank-Buss
Frank-Buss / overflow.txt
Created January 5, 2025 19:05
demonstration of the overflow problem reported here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30475
frank@wopr:~/tmp$ cat overflow.c
#include <assert.h>
#include <stdio.h>
int foo(int a) {
assert(a+100 > a);
printf("%d %d\n",a+100,a);
return a;
}
@Frank-Buss
Frank-Buss / ip.py
Created September 23, 2024 20:45
get your IP address
#!/usr/bin/env python3
import requests
response = requests.get("https://httpbin.org/ip")
data = response.json()
ip = data.get("origin", "Unknown")
print(f"Your IP address is: {ip}")
@Frank-Buss
Frank-Buss / bitflips.py
Created September 17, 2024 07:58
Counts all possible single bit flip names for domain
import re
import sys
# List of valid TLDs (this is a small subset, you may want to use a more comprehensive list)
VALID_TLDS = set(['com', 'org', 'net', 'edu', 'gov', 'io', 'co', 'uk', 'de', 'fr', 'jp', 'cn', 'au', 'us'])
def is_valid_domain(domain):
pattern = r'^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z]{2,})+$'
if not re.match(pattern, domain):
return False
@Frank-Buss
Frank-Buss / test.sh
Created July 22, 2024 20:15
testing signing and verifying a file of zeros
# create a new private key
frank@hal9000:~/tmp$ openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048
..+.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.+.........+.+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.....+..+...+....+......+..+...+.......+..+....+..+...+....+..+......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.+..+.........+......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.....+.........+....+.....+..........+..+.........+....+..+............+.+..+.......+.....+.+...............+..+............+...+...+.+......+............+...............+..+.............+........+...+......+....+......+........+...+..........+............+..+....+..+...+....+..+....+......+.....+...+.+.....+................+.......................+.+.........+...........+.+...+..+.............+......+..............+...+....+........+.+..+.....
@Frank-Buss
Frank-Buss / replace.py
Created May 15, 2024 16:54
pin github workflow dependencies
#!/usr/bin/env python3
# automatically pins all your workflows, see
# https://github.com/fmtlib/fmt/issues/3449
# for details
import sys
import requests
import os
@Frank-Buss
Frank-Buss / lufs.py
Created February 5, 2024 05:46
LUFS momentary and short analyzer
# Audio loudness calculation and normalization.
# The LUFS calculations here are all based on:
# ITU documentation: https://www.itu.int/dms_pubrec/itu-r/rec/bs/R-REC-BS.1770-4-201510-I!!PDF-E.pdf
# EBU documentation: https://tech.ebu.ch/docs/tech/tech3341.pdf
# pyloudnorm by csteinmetz1: https://github.com/csteinmetz1/pyloudnorm
# loudness.py by BrechtDeMan: https://github.com/BrechtDeMan/loudness.py
# Special thanks to these authors!
# I just rewrote some codes to enable short-term and momentary loudness calculations and normalizations for more convinent batch processing of audio files.
import numpy as np