Skip to content

Instantly share code, notes, and snippets.

@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")
@Frank-Buss
Frank-Buss / diagram-test.md
Created November 9, 2022 06:11
testing some mermaid diagrams

Sequence Diagram test

sequenceDiagram
participant Alice
participant Bob
Alice->>John: Hello John, how are you?
loop Healthcheck
    John->>John: Fight against hypochondria
end
Note right of John: Rational thoughts prevail!
@Frank-Buss
Frank-Buss / test.c
Created August 19, 2022 17:14
printing call stack on assert and segfaults
#include <assert.h>
#include <signal.h>
#include <stdio.h>
#include <execinfo.h>
/*
compile this program like this:
gcc -Wall -O0 -g -fsanitize=address -fno-omit-frame-pointer -finstrument-functions test.c -o test
@Frank-Buss
Frank-Buss / sell.py
Created May 7, 2022 07:14
listing NFTs on OpenSea for sale with Selenium and a Python script
# library installation:
# pip3 install -U selenium
# pip3 install webdriver-manager
#
# usage:
# first start Chrome in debug mode:
# google-chrome --remote-debugging-port=1234
# then:
# - sign in to MetaMask and select right network and account
# - connect to OpenSea
@Frank-Buss
Frank-Buss / star.cpp
Created April 19, 2022 23:49
star scroller effect program for Watcom C and DOS, which I wrote in 1995
#include <conio.h>
#include <time.h>
#include <stdlib.h>
extern void waitvsync();
extern unsigned short setvideomode();
extern void restorevideomode(unsigned short old);
extern void setcolor(unsigned short farbe);
extern void setpixel(unsigned short x,unsigned short y);