Skip to content

Instantly share code, notes, and snippets.

# 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
@Frank-Buss
Frank-Buss / monopoly.c
Last active January 7, 2024 11:59
How likely is it that 5 players are on the same field in Monopoly? Ignoring go to jail, about 1 in 2.5 million dice rolls. Discussion, mathematical results, and improvements here: https://twitter.com/eevblog/status/1743948240616411247
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#define PLAYERS 5
uint8_t pos[PLAYERS];
int random2to12() {
return (rand() % 11) + 2;
@Frank-Buss
Frank-Buss / WizardLM.py
Last active December 14, 2023 01:13
Sample script how to run the uncensored WizardLM LLM
#!/usr/bin/env python3
#
# Test script for the uncensored WizardLM model:
# https://huggingface.co/TheBloke/WizardLM-7B-uncensored-GGML
#
# Tested on Mac Mini M1, with 16 GB RAM. Needs some libraries:
#
# pip install torch transformers accelerate bitsandbytes
# CT_METAL=1 pip install ctransformers --no-binary ctransformers
#