Skip to content

Instantly share code, notes, and snippets.

View pepijndevos's full-sized avatar

Pepijn de Vos pepijndevos

View GitHub Profile
@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
@pepijndevos
pepijndevos / recruiter.txt
Last active February 15, 2022 14:19
A counter-copy-pasta for recruiter spam
We're no strangers to jobs
You know the rules and so do I
A full commitment's what I'm thinking of
You wouldn't get this from any other guy
You're just gonna tell me what you're paying
Gotta make you understand
Never gonna give my pay
Never gonna let you know