Skip to content

Instantly share code, notes, and snippets.

View billywhizz's full-sized avatar
🤓
always be learning

Andrew Johnston billywhizz

🤓
always be learning
View GitHub Profile
@billywhizz
billywhizz / clangd.md
Created December 6, 2025 23:53 — forked from Strus/clangd.md
How to use clangd C/C++ LSP in any project

How to use clangd C/C++ LSP in any project

tl;dr: If you want to just know the method, skip to How to section

Clangd is a state-of-the-art C/C++ LSP that can be used in every popular text editors like Neovim, Emacs or VS Code. Even CLion uses clangd under the hood. Unfortunately, clangd requires compile_commands.json to work, and the easiest way to painlessly generate it is to use CMake.

For simple projects you can try to use Bear - it will capture compile commands and generate compile_commands.json. Although I could never make it work in big projects with custom or complicated build systems.

But what if I tell you you can quickly hack your way around that, and generate compile_commands.json for any project, no matter how compilcated? I have used that way at work for years, originaly because I used CLion which supported only CMake projects - but now I use that method succesfully with clangd and Neovim.

// stb_c_lexer.h 0.01 -- public domain Sean Barrett 2013
// lexer for making little C-like languages with recursive-descent parsers
//
// This file provides both the interface and the implementation.
// To instantiate the implementation,
// #define STB_C_LEXER_IMPLEMENTATION
// in *ONE* source file, before #including this file.
//
// The default configuration is fairly close to a C lexer, although
// suffixes on integer constants are not handled (you can override this).
@billywhizz
billywhizz / README.md
Last active November 7, 2025 01:29
fifos

this will deadlock the process if we run it in same process as js

@billywhizz
billywhizz / c_nostd.txt
Created August 18, 2025 23:28 — forked from tcoppex/c_nostd.txt
Writing C software without the standard library [Linux Edition] - Franc[e]sco's Gopherspace
###################################################################
Writing C software without the standard library
Linux Edition
###################################################################
There are many tutorials on the web that explain how to build a
simple hello world in C without the libc on AMD64, but most of them
stop there.
I will provide a more complete explanation that will allow you to
build yourself a little framework to write more complex programs.
@billywhizz
billywhizz / vsock-get-cid.py
Created July 14, 2025 00:36 — forked from stefano-garzarella/vsock-get-cid.py
vsock: get local CID using the available ioctl
#!/usr/bin/env python3
import socket
import struct
import fcntl
with open("/dev/vsock", "rb") as fd:
r = fcntl.ioctl(fd, socket.IOCTL_VM_SOCKETS_GET_LOCAL_CID, " ")
cid = struct.unpack("I", r)[0]
print("Local CID: {}".format(cid))
@billywhizz
billywhizz / base model trends.md
Created July 2, 2025 20:48 — forked from rain-1/base model trends.md
base model trends.md
@billywhizz
billywhizz / rdiff-example.sh
Created June 21, 2025 00:10 — forked from jpillora/rdiff-example.sh
rdiff file example
# $ apt install rdiff
# $ rdiff --help
# Usage: rdiff [OPTIONS] signature [BASIS [SIGNATURE]]
# [OPTIONS] delta SIGNATURE [NEWFILE [DELTA]]
# [OPTIONS] patch BASIS [DELTA [NEWFILE]]
# Options:
# -v, --verbose Trace internal processing
# -V, --version Show program version
# -?, --help Show this help message
import { Stats } from './lib/bench.js'
import { SQL } from "bun";
const pool_size = 4
/*
CREATE TABLE Test (
id integer NOT NULL,
PRIMARY KEY (id)
);
@billywhizz
billywhizz / padding.js
Created May 30, 2025 23:49 — forked from clochix/padding.js
JavaScript padding tolerant to ANSI escape sequences
/**
* Display a string with padding
*
* @param {String} str String to pad
* @param {Integer} l padding length
* @param {Boolean} [r] true for right padding
*
* @return {String}
*/
function pad(str, l, r) {
@billywhizz
billywhizz / sve2.md
Created May 17, 2025 21:36 — forked from zingaburga/sve2.md
ARM’s Scalable Vector Extensions: A Critical Look at SVE2 For Integer Workloads

ARM’s Scalable Vector Extensions: A Critical Look at SVE2 For Integer Workloads

Scalable Vector Extensions (SVE) is ARM’s latest SIMD extension to their instruction set, which was announced back in 2016. A follow-up SVE2 extension was announced in 2019, designed to incorporate all functionality from ARM’s current primary SIMD extension, NEON (aka ASIMD).

Despite being announced 5 years ago, there is currently no generally available CPU which supports any form of SVE (which excludes the [Fugaku supercomputer](https://www.fujitsu.com/global/about/innovation/