Skip to content

Instantly share code, notes, and snippets.

@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
#
@Frank-Buss
Frank-Buss / riscv.md
Created July 30, 2023 02:58
run RISC-V assembler on x86_64 Debian Linux

Run RISC-V assembler programs on Debian Linux

This tutorial shows how to compile and run RISC-V assembler code on Debian Linux systems, which are not running on a RISC-V system (e.g. x86_64).

Install the toolchain and emulator

sudo apt-get install qemu qemu-system-misc qemu-user gcc-riscv64-unknown-elf

Create a hello world program

Save this as hello.s:

@Frank-Buss
Frank-Buss / move.py
Created January 11, 2023 21:48
PyGame sprite movement
# ChatGPT result of this question:
# write a Python script, where the user can move a sprite with cursor keys, using PyGame
import pygame
# Initialize PyGame
pygame.init()
# Set up the screen (width, height, caption)
size = (700, 500)
@Frank-Buss
Frank-Buss / test.cljs
Last active December 4, 2022 02:04
first Clojure code, day 3 of advent of code 2022
(ns test
(:require [clojure.string :refer [split-lines]])
(:require [clojure.set :refer [intersection]]))
(def rucksacks "vJrwpWtwJgWrhcsFMMfFFhFp
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
PmmdzqPrVvPwwTWBwg
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw")