Skip to content

Instantly share code, notes, and snippets.

@catbraincell
catbraincell / gerber_cleanup.py
Created October 19, 2025 12:19
Remove tool information and file path from gerber & nc drill files
import os
import re
import fnmatch
# Regex replacements for .g* files
g_patterns = [
(re.compile(r'^(G04\s+#@!\s+TF\.GenerationSoftware)[^*]*\*$', re.MULTILINE),
r'\1*'),
(re.compile(r'^(G04\s+#@!\s+TF\.SameCoordinates)[^*]*\*$', re.MULTILINE),
r'\1*')
@catbraincell
catbraincell / bidir_shiftreg.v
Last active October 20, 2025 03:19
Synthesizable variable-length bidirectional shift register
module bidir_shiftreg #(
parameter integer W = 32
) (
input wire clk,
input wire nrst,
input wire lsbfirst, // 1 = LSB-first shift (right), 0 = MSB-first (left)
input wire [$clog2(W)-1:0] N, // active bits val[N:0]
input wire [W-1:0] load, // parallel load
input wire load_en,
output reg [W-1:0] val, // parallel output
@catbraincell
catbraincell / pytubefix_gui.py
Last active November 9, 2025 00:31
A minimal GUI for pytubefix with a/v merging support (call ffmpeg automatically)
#!/usr/bin/env python3
import sys
import re
import os
import shutil
import subprocess
import tempfile
from dataclasses import dataclass
from typing import List, Optional
@catbraincell
catbraincell / build_llama_cpp_windows_amd.bat
Last active June 5, 2025 08:56
compile llama.cpp on windows with AMD ROCm
'BROKEN, DONT TRY
D:\
set PATH=%HIP_PATH%\bin;%PATH%
cd llama.cpp
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
bootstrap-vcpkg.bat
vcpkg.exe install curl:x64-windows
@catbraincell
catbraincell / remove_amd_adrenalin.reg
Created November 2, 2024 01:34
Remove "AMD Software: Adrenalin Edition" from Windows Explorer context menu
Windows Registry Editor Version 5.00
[-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shellex\ContextMenuHandlers\ACE]
@catbraincell
catbraincell / factorio_update.sh
Last active November 8, 2024 11:44
Factorio server auto update script and systemd service file.
#!/bin/bash
# if the script hangs on wget download, replace `wget` with `wget -4`
: '
/etc/systemd/system/factorio.service
[Unit]
Descritpion=Factorio Headless Server
After=network.target
@catbraincell
catbraincell / attitude_3d.py
Created September 11, 2023 07:11
3d attitude display with pyqt5
import sys
import math
import numpy as np
from stl import mesh # pip install numpy-stl
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
import pyqtgraph as pg
from pyqtgraph.opengl import GLViewWidget, GLGridItem, MeshData, GLMeshItem
@catbraincell
catbraincell / qt_creator_gdb_crash_on_windows_fix.md
Last active July 16, 2023 07:55
Fix the "Qt Debugger: The GDB process terminated" error on windows

Some MinGW gdb versions will crash on info registers command. [https://sourceware.org/bugzilla/show_bug.cgi?id=26304]

Once a debugger panel in QtCreator opened, it will keep sending info registers command to gdb.
To stop this, remove Debugger.MainWindow/ChangedDocks and Debugger.MainWindow/State fields from C:\Users\[UserName]\AppData\Roaming\QtProject\QtCreator.ini

[Debugger.MainWindow]
AutoHideTitleBars=true
ShowCentralWidget=true
ChangedDocks=[REMOVED THIS]
@catbraincell
catbraincell / base_block.hpp
Last active July 16, 2023 07:47
a simple replacement for gnuradio runtime / block class
#pragma once
#include <vector>
#include <stdexcept>
#define SDR_DICT
#ifdef SDR_DICT
#include <list>
#include <map>
@catbraincell
catbraincell / mysudo.md
Last active May 25, 2023 08:47
mysudo - GUI prompt to start a GUI application as root

Add this line to ~/.bashrc
alias mysudo='pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY'