Skip to content

Instantly share code, notes, and snippets.

View 0xFieldsy's full-sized avatar

Adam Fields 0xFieldsy

View GitHub Profile
@0xFieldsy
0xFieldsy / vulkan-ubuntu.md
Created June 28, 2026 12:11
Install Mesa Vulkan Drivers on Ubuntu 24.04 (Noble Numbat)

If a Vulkan build of a GPU application like llama.cpp or stable-diffusion.cpp cannot find your graphics card, you need updated Mesa Vulkan drivers.

Mesa Vulkan drivers are open-source user-space drivers that translate Vulkan API calls into instructions your GPU can execute.

To install the latest drivers on Ubuntu, use the Kisak Mesa PPA. Kisak is a developer at Valve.

Prerequisites

sudo apt update
@0xFieldsy
0xFieldsy / rocm-wsl.md
Last active June 28, 2026 12:12
Install AMD ROCm on WSL

This assumes you already have AMD Adrenalin installed on the Windows side with up-to-date chipset drivers.

Even if you are not compiling GPU programs, you still need the shared libraries for binaries that dynamically link to them at runtime. For example, running ldd llama-server reports that it requires many libhip*.so and libroc*.so files. If these are not in your LD_LIBRARY_PATH, the program will crash.

Install amdgpu-install

Go to https://repo.radeon.com/amdgpu-install and find the latest release for your OS. I'm on Ubuntu 24 (Noble):

wget https://repo.radeon.com/amdgpu-install/7.2.4/ubuntu/noble/amdgpu-install_7.2.4.70204-1_all.deb
@0xFieldsy
0xFieldsy / fix-gpg-keyboxd-windows.md
Last active February 16, 2026 19:42
Fix GnuPG Slow Commit Signing on Windows

Historically, GnuPG stored keys in a flat file (pubring.gpg). Modern versions moved toward keyboxd, a background SQLite-based daemon.

When you run a command like git commit or gpg --list-keys, Windows has to do a bunch of things, and for whatever reason those things are slow.

To shift this work to login time:

  1. Open Task Scheduler
  2. Click Create Task and give it a name
  3. Add the At log on trigger
  4. Add an action to Start a program with powershell.exe and the arguments:
@0xFieldsy
0xFieldsy / msvc-windows-terminal.md
Last active January 24, 2026 15:53
MSVC (cl) in Windows Terminal

I wanted to build C programs on Windows 11 without WSL. I then wanted to be able to open a terminal tab with the MSVC compiler/linker (cl) environment set up.

Note

These instructions target x64; substitute the appropriate values for ARM.

Installation

Install Visual Studio Build Tools via Winget:

@0xFieldsy
0xFieldsy / bash-heredoc-variable-with-read.md
Last active January 24, 2026 15:53
Assign heredoc to variable in Bash

Instead of concatenation:

str=""
str+="This is a\n"
str+="multiline string"

You can use a heredoc:

@0xFieldsy
0xFieldsy / aspect_ratio.py
Created August 26, 2024 20:21
Python Aspect Ratio
def aspect_ratio(width=0, height=0):
if width <= 0 or height <= 0:
return None
a, b = width, height
while b:
a, b = b, a % b
gcd = a
return (width // gcd, height // gcd)
@0xFieldsy
0xFieldsy / relative-path-in-scripts.md
Last active January 24, 2026 15:54
Maintain Relative Paths in Shell Scripts

You can use the $0 variable to get the script's path:

cat "$(dirname $0)/some/file.txt"

If you have Bash, you can use ${BASH_SOURCE[0]} instead of $(dirname $0), to avoid spawning a subshell. To test, create 2 files in /tmp/test:

mkdir -p /tmp/test
@0xFieldsy
0xFieldsy / cloudflare-tunnel-instructions.md
Last active January 24, 2026 15:55
Cloudflare Tunnel Instructions

This assumes you have a free Cloudflare account and you're already using it as your DNS provider. Also, this is going to be using cloudflared directly on-demand, rather than an always-on systemd service. Based on the official tutorial.

Install cloudflared

Installing the system service is optional.

# mac
brew install cloudflared
@0xFieldsy
0xFieldsy / favicon.sh
Last active April 5, 2024 17:58
Favicon and Webmanifest Script
#!/usr/bin/env bash
set -euo pipefail
# Generates favicons and a webmanifest from a single image
# https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs
#
# Usage:
# favicon.sh <file> [dir] [flags]
#
# Args:
@0xFieldsy
0xFieldsy / windows-ssh-no-password-with-keys-wsl2.md
Last active August 3, 2026 21:38
Windows SSH Server with Password-less Key Authentication and Default WSL2 Shell

I wanted to be able to SSH into my Windows laptop directly into Linux. I also wanted to disable password authentication and only allow public key (RSA in my case) authentication.

Scott Hanselman wrote a blog post on how to make your default WSL2 distro your default shell for SSH. Windows OS Hub published an article on using public key authentication. These were both helpful resources.

I'll assume you're already familiar with using SSH keys. If not, this article at DigitalOcean is very informative.

Add your public key to your authorized keys file

First thing you want to do is create the file $HOME\.ssh\authorized_keys. If you run into issues, it could be due to incorrect file ownership.