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 / Makefile
Created April 19, 2025 23:13 — forked from alifarazz/Makefile
A Linux process cloning example using Clone().
all: default
default: waitpid waitpid_optimized
waitpid: waitpid.c Makefile
$(CC) -Wall -Werror -std=gnu17 -ggdb -o waitpid waitpid.c
waitpid_optimized: waitpid.c Makefile
$(CC) -Wall -Werror -std=gnu17 -Ofast -o waitpid_optimized waitpid.c
@billywhizz
billywhizz / main.c
Created March 29, 2025 20:32 — forked from mattiasgustavsson/main.c
Minimal code example for creating a window to plot pixels to
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <windows.h>
#pragma comment( lib, "user32.lib" )
#pragma comment( lib, "gdi32.lib" )
#define SCRW 640
#define SCRH 480
@billywhizz
billywhizz / xcb_shmimg.c
Created March 29, 2025 20:31 — forked from datenwolf/xcb_shmimg.c
minimal example of using XCB to set up a framebuffer to draw to an X11 window
#include <stdlib.h>
#include <stdio.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <xcb/xcb.h>
#include <xcb/shm.h>
#include <xcb/xcb_image.h>
@billywhizz
billywhizz / jq.md
Created March 19, 2025 00:20 — forked from jwbee/jq.md
Make Ubuntu packages 90% faster by rebuilding them

Make Ubuntu packages 90% faster by rebuilding them

TL;DR

You can take the same source code package that Ubuntu uses to build jq, compile it again, and realize 90% better performance.

Setting

I use jq for processing GeoJSON files and other open data offered in JSON format. Today I am working with a 500MB GeoJSON file that contains the Alameda County Assessor's parcel map. I want to run a query that prints the city for every parcel worth more than a threshold amount. The program is

@billywhizz
billywhizz / index.ts
Created February 16, 2025 16:16 — forked from zackradisic/index.ts
Visitor pattern vs sum types and pattern matching
// First, let's look at the traditional visitor pattern
// This is how we might implement a simple expression evaluator
// Traditional Visitor Pattern
namespace Traditional {
// Abstract base class for expressions
abstract class Expr {
abstract accept<T>(visitor: ExprVisitor<T>): T;
}
@billywhizz
billywhizz / build-tmux.sh
Created February 15, 2025 18:34 — forked from mbreese/build-tmux.sh
HOWTO build a statically linked tmux in one script (downloads and builds dependencies from source)
#!/bin/bash
TARGETDIR=$1
if [ "$TARGETDIR" = "" ]; then
TARGETDIR=$(python -c 'import os; print os.path.realpath("local")')
fi
mkdir -p $TARGETDIR
libevent() {
curl -LO https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
tar -zxvf libevent-2.0.22-stable.tar.gz
@billywhizz
billywhizz / vsock-notes.md
Created February 10, 2025 01:26 — forked from nrdmn/vsock-notes.md
vsock notes

vsock notes

about vsocks

Vsocks are a means of providing socket communication (either stream or datagram) directly between VMs and their host operating system. The host and each VM have a 32 bit CID (Context IDentifier) and may connect or bind to a 32 bit port number. Ports < 1024 are privileged ports.

@billywhizz
billywhizz / active.md
Created January 2, 2025 12:28 — forked from paulmillr/active.md
Most active GitHub users (by contributions). http://twitter.com/paulmillr

Most active GitHub users (git.io/top)

The list would not be updated for now. Don't write comments.

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Wed, 21 Sep 2022 till Thu, 21 Sep 2023.

Because of GitHub search limitations, only 1000 first users according to amount of followers are included. If you are not in the list you don't have enough followers. See raw data and source code. Algorithm in pseudocode:

githubUsers
@billywhizz
billywhizz / simple_epoll_inotify_test.c
Created December 29, 2024 20:01 — forked from dalehamel/simple_epoll_inotify_test.c
Test inotify on memfd with epoll api
#include <stdio.h>
#include <sys/inotify.h>
#include <sys/time.h>
#include <sys/epoll.h>
#include <errno.h>
#include <linux/memfd.h>
#include <sys/mman.h>
#include <sys/syscall.h>
@billywhizz
billywhizz / exit_the_cloud.md
Created October 24, 2024 20:57 — forked from rameerez/exit_the_cloud.md
☁️ How I got off the cloud and migrated everything from AWS to a VPS in Hetzner

☁️ How I got off the cloud and migrated everything from AWS to a VPS in Hetzner

This is an opinionated handbook on how I migrated all my Rails apps off the cloud and into VPS.

This is how I manage real production loads for my Rails apps. It assumes:

  • Rails 7+
  • Ruby 3+
  • PostgreSQL
  • Ubuntu Server 24.04
  • Capistrano, Puma, Nginx