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 / 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
@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 / build.sh
Last active November 18, 2024 00:11
dumb-benchmark
GOAMD64=v2 go build foo.go
@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
WITH RECURSIVE transitive_dependencies AS (
SELECT package_id AS dependency_id, package_id AS root_id
FROM dependencies
WHERE kind = 'runtime'
UNION ALL
SELECT d.package_id, td.root_id
FROM dependencies d
JOIN transitive_dependencies td ON td.dependency_id = d.package_id AND td.dependency_id <> td.root_id -- Avoid self-joins
WHERE d.kind = 'runtime'
),