Skip to content

Instantly share code, notes, and snippets.

View pepijndevos's full-sized avatar

Pepijn de Vos pepijndevos

View GitHub Profile
@pepijndevos
pepijndevos / opcodes.txt
Created August 24, 2016 14:44
Opcode distribution
1 aesdeclast
1 aesimc
1 cmovp
1 fcmovbe
1 fcmove
1 fcmovnbe
1 fdivr
1 fdivs
1 fild
1 fmuls
@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)
@pepijndevos
pepijndevos / lazy_sort.clj
Created May 2, 2011 12:49
Lazy sorting implementations in Clojure
(ns lazy-sort)
(defn qsort [[head & tail]]
(when head
(lazy-cat (qsort (filter #(< % head) tail))
[head]
(qsort (remove #(< % head) tail)))))
(defn merge*
[[f1 & r1 :as l1] [f2 & r2 :as l2]]
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 / 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 / upload.py
Last active October 2, 2022 18:20
Upload code to the Robot Inventor hub
import base64
import json
import sys
import serial
import random
import os
if len(sys.argv) != 4:
print(f"Usage\n{sys.argv[1]} tty code.py slot")
exit()
@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 / 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