Skip to content

Instantly share code, notes, and snippets.

View LowByteFox's full-sized avatar
🦈
I like sharks

LowByteFox

🦈
I like sharks
View GitHub Profile
@LowByteFox
LowByteFox / main.c
Last active August 16, 2025 05:20
RefCell<T> from Rust in C
#include "refcell.h"
MAKE_REFCELL(int, int);
int main()
{
struct refcell_int ref = make_int_ref(0);
const int *borrow1 = refcell_int_borrow(&ref);
const int *borrow2 = refcell_int_borrow(&ref);
const int *borrow3 = refcell_int_borrow(&ref);
@LowByteFox
LowByteFox / readme.md
Last active November 19, 2023 11:06
Compiling bun on FreeBSD
  1. Install FreeBSD 13.2 in a VM and create dummy account, call it bun for example
  2. Install these packages as root using pkg install

ccache cmake git go libiconv libtool gmake ninja pkgconf python rust unzip ruby automake bash llvm16 llvm17 gcc13-dev npm icu libsysinfo

  1. Change bun's shell to /usr/local/bin/bash using chsh ( I recommend installing neovim and running the command as EDITOR=nvim chsh )

now always login as bun user

  1. Clone these repos - there is space between urls, git clone each one separately

https://github.com/Bun-BSD/codegen.git https://github.com/oven-sh/WebKit.git https://github.com/ziglang/zig.git https://github.com/Bun-BSD/bun.git Now we will compile all deps, make sure you are in home directory each time

  1. Building WebKit
    1. In your home directory create webkit.sh and write this into it
const std = @import("std");
pub fn Trie(comptime T: type) type {
return struct {
data: ?T,
childs: []?*Trie(T),
pub fn init(allocator: std.mem.Allocator) !*Trie(T) {
var trie = try allocator.create(Trie(T));
trie.childs = try allocator.alloc(?*Trie(T), 95);
@LowByteFox
LowByteFox / index.ts
Created April 7, 2023 08:46
Bun bun bundling files and being node_modulesless
// code extracted from https://github.com/Fire-The-Fox/buchta/blob/master/src/bundler.ts
// Show it some ❤️ by giving it a ⭐
import { spawnSync } from "bun";
import { existsSync, readFileSync, unlinkSync, writeFileSync } from "fs";
import { dirname, relative } from "path";
// run as bun ./index.ts a.ts b.ts ...
const a = process.argv
a.shift()
a.shift()
@LowByteFox
LowByteFox / Dockerfile
Created April 3, 2023 15:41
Docker image with alpine and bun
# Bun docker container running on alpine linux
# Dockerfile based on https://github.com/oven-sh/bun/blob/main/dockerhub/Dockerfile-alpine
FROM frolvlad/alpine-glibc AS build
WORKDIR /tmp/
RUN apk update && apk upgrade && apk add unzip
ADD https://github.com/oven-sh/bun/releases/latest/download/bun-linux-x64.zip bun-linux-x64.zip
RUN unzip bun-linux-x64.zip