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 / README.md
Last active January 24, 2025 21:57
node SEA loading node addon from memory experiment

see the changes

caveats

  • this is just PoC code. not meant to represent a desired api. just enough to get things to work on linux.
  • this technique will only work on linux but there are possibly other techniques that would work on macos and windows. more to follow.
  • it will only work if procfs is mounted. dlopen is called with the path /proc/self/${fd} with the fd from memfd_create
  • you will still have to deal with the issue of any external dependencies of the node addons you want to embed in the SEA
@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
#!/bin/bash
git clone https://github.com/just-js/lo.git
cd lo/
make lo
export LO_HOME=$(pwd)
./lo build binding bestlines
cd ..
lo/lo build runtime test-dlopen
./test-dlopen