Skip to content

Instantly share code, notes, and snippets.

View nielsvaes's full-sized avatar

Niels Vaes nielsvaes

View GitHub Profile
@nielsvaes
nielsvaes / claude_permissions.json
Last active April 7, 2026 07:47
Permissions to work
"permissions": {
"allow": [
"Bash(*)",
"WebSearch",
"WebFetch",
"Edit",
"Write",
"Find",
"Read",
"Search"
#!/bin/bash
# Variables we need to make things easier later on.
CONFIGFS="/sys/kernel/config"
GADGET="$CONFIGFS/usb_gadget"
VID="0x0525"
PID="0xa4a2"
SERIAL="0123456789"
MANUF=$(hostname)
echo "dtoverlay=dwc2,dr_mode=otg" | sudo tee -a /boot/config.txt
sudo apt install -y git meson libcamera-dev libjpeg-dev
git clone https://gitlab.freedesktop.org/camera/uvc-gadget.git
cd uvc-gadget
make uvc-gadget
cd build
sudo meson install
sudo ldconfig
cd ~/
wget https://gist.githubusercontent.com/nielsvaes/17be5d737f1314a396cc7c9b80f1135f/raw/c0295876cad0588d1c25161d7c10dad9408e715c/rpi-uvc-gadget.sh
@nielsvaes
nielsvaes / blackjack_sim.py
Created August 1, 2024 18:00
A very simple card counting blackjack simulator
import random
import logging
import matplotlib.pyplot as plt
class ShouldLog:
yes = logging.INFO
no = logging.ERROR
# Set up logging
logging.basicConfig(
@nielsvaes
nielsvaes / zip_folder_to_file.py
Created July 17, 2023 12:56
Zip a folder to a file
import os
import zipfile
def make_zipfile(output_filename, source_dir):
relroot = os.path.abspath(os.path.join(source_dir, os.pardir))
with zipfile.ZipFile(output_filename, "w", zipfile.ZIP_DEFLATED) as zip:
for root, dirs, files in os.walk(source_dir):
zip.write(root, os.path.relpath(root, relroot))
for file in files:
filename = os.path.join(root, file)
@nielsvaes
nielsvaes / versioner.py
Created August 30, 2022 08:04
Make local versions of files
import stat
import os
import shutil
import datetime
LOCAL_HISTORY = ".local_history"
AUTO_PREFIX = ".version__"
NAMED_PREFIX = ".named__"
READONLY = 33060
WRITABLE = 33206
@nielsvaes
nielsvaes / radio_beacon.lua
Created February 24, 2022 22:23
DCS - RadioBeacon
-- Let's create a beacon for a unit in distress.
-- Frequency will be 40MHz FM (home-able by a Huey's AN/ARC-131)
-- The beacon they use is battery-powered, and only lasts for 5 min
local UnitInDistress = UNIT:FindByName("CRASHED HELICOPTER")
local UnitBeacon = UnitInDistress:GetBeacon()
-- Set the beacon and start it
UnitBeacon:RadioBeacon("MySoundFileSOS.ogg", 40, radio.modulation.FM, 20, 5*60)
@nielsvaes
nielsvaes / change_tanker_speed.lua
Last active February 17, 2022 12:57
DCS - Change tanker speed
-- DCS lua
local tanker = GROUP:FindByName("TANKER")
local route = tanker:GetTaskRoute()
for _, each in pairs(route) do
tanker:I(each["x"])
tanker:I(each["y"])
end
@nielsvaes
nielsvaes / lase_target.lua
Created January 5, 2022 20:48
DCS MOOSE - Lase target
local recce = UNIT:FindByName("DRONE UNIT")
local lasing_drone = SPOT:New(recce)
local target = UNIT:FindByName("LASER TARGET")
lasing_drone:LaseOn(target, 1688, 600)
MESSAGE:New("Lasing Target!"):ToAll()
@nielsvaes
nielsvaes / spawn_from_mark.lua
Created January 4, 2022 18:06
DCS MOOSE - Spawn from Mark
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by niels.
--- DateTime: 1/4/2022 3:35 PM
---
local function split_string(str, delimiter)
local result = {};
for match in (str ..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);