Skip to content

Instantly share code, notes, and snippets.

View pepijndevos's full-sized avatar

Pepijn de Vos pepijndevos

View GitHub Profile
@pepijndevos
pepijndevos / gst_hdr.py
Created August 28, 2025 15:36
process high speed footage into low speed HDR footage
#!/usr/bin/env python3
import sys
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GLib
import numpy as np
from collections import deque
if len(sys.argv) != 3:
@pepijndevos
pepijndevos / hvm.py
Created November 11, 2024 17:31
HVM in Python
"""
HVML (Higher-order Virtual Machine Language) Implementation
The runtime memory consists of a vector of ports (represented as Terms), where each port has:
- A 3-bit tag indicating the type of node it connects to
- A location value pointing to where that node's ports begin in memory
Memory Model
-----------
A port represents a wire connected to a node's main port. The tag indicates the type
@pepijndevos
pepijndevos / aur.sh
Created August 12, 2024 09:01
Barebones AUR wrapper
#!/bin/bash
# Function to clone AUR package
clone_package() {
if [ -d ~/aur/"$1" ]; then
echo "Package '$1' already exists."
else
git clone "https://aur.archlinux.org/$1.git" ~/aur/"$1"
echo "Package '$1' cloned successfully."
fi
@pepijndevos
pepijndevos / horn.py
Created May 14, 2024 20:38
image to sound
from PIL import Image
from PIL import ImageFilter
import numpy as np
import matplotlib.pyplot as plt
from scipy.io.wavfile import write
threshold = 200
# Open image and convert to numpy array
img = Image.open("matterhorn.png")
@pepijndevos
pepijndevos / run.sh
Created November 2, 2023 18:05
Automatically refactor the code in an entire github organization
#!/bin/bash
set -ex
# Define your GitHub username and organization name
YOUR_USERNAME="pepijndevos"
ORG_NAME="SciML"
# Iterate through the organization's repositories
REPO_LIST=$(gh repo list $ORG_NAME --json name --limit 1000 --no-archived)
using ControlSystems
using Plots
# calculate the inertia from bifilar pendulum experiment
# https://www.youtube.com/watch?v=IdhV3lphRcc
L = 1.8 # length of the pendulum
D = 0.18 # distance between the wires
b = D/2
g = 9.81 # graviational constant
@pepijndevos
pepijndevos / counter.hy
Created August 23, 2022 21:13
Amaranth in Hy
(import amaranth *)
(defn domain [domain #* expr] (domain.__iadd__ expr))
(defmacro mwhen [m condition #* body]
`(do
(with [(m.If ~condition)]
~body)))
(defmacro mif [m condition pos neg]
@pepijndevos
pepijndevos / schema.py
Last active August 11, 2022 12:13
Parse mapbox vector tiles with minipb on micropython
import minipb
import zlib
value = (('string_value', 'U'),
('float_value', 'f'),
('double_value', 'd'),
('int_value', 't'),
('uint_value', 'T'),
('sint_value', 'z'),
('bool_value', 'b'))
@pepijndevos
pepijndevos / patch.py
Created June 12, 2022 20:05
Gowin IDE patcher
#!/usr/bin/python3
import os
import re
import subprocess
import mmap
def patch(filename : str, bytes):
subprocess.run(["cp",filename, filename + '_patched'])
with open(filename + "_patched", "r+b") as f:
@pepijndevos
pepijndevos / randomize.sh
Last active April 10, 2022 10:09
Replace colors in an image with random ones and assemble into a montage
set -ex
ORIGINAL="fox.jpg"
OG_SHIRT="#224e2b"
OG_PANTS="#9f6e4e"
function rand {
echo $(($1 + ($RANDOM % ($2 - $1))));
}
mkdir -p tiles