Skip to content

Instantly share code, notes, and snippets.

@jwhear
jwhear / build.zig
Created February 20, 2023 21:51
No unistd.h for macos 10
const std = @import("std");
const CrossTarget = std.zig.CrossTarget;
pub fn build(b: *std.Build) void {
const target = CrossTarget{
.cpu_arch = .x86_64,
.os_tag = .macos,
.os_version_min = CrossTarget.OsVersion{ .semver = .{ .major = 10, .minor = 14, .patch = 0 } },
.abi = .none,
};

Here's a "fun" challenge for Zig's comptime design. I have implemented the Adaptive Radix Tree and am now looking to generalize it. To save you from having to read the whole paper, it's a radix tree but inner nodes can be one of several types in an attempt to reduce node size and corresponding memory cache issues. My Zig implementation of the paper works fine, but I want to generalize so that, for instance, when using smaller key types, the types of the inner nodes can be changed. For instance, if using []const u5, a fully dense node has only 32 children so the Node48 type doesn't make sense.

Here's a sketch of what the ART types look like with various details elided:

pub const Key = []const u8;
pub const KeySegment = u8;
pub const Payload = usize;
pub const KeySpace = std.math.maxInt(KeySegment) + 1;
@jwhear
jwhear / Dockerfile.debian
Created July 28, 2022 14:33
LiteFS docker test (Debian)
FROM debian
RUN apt update && apt install -y fuse3 libfuse3-dev sqlite3 wget zip
RUN wget https://releases.hashicorp.com/consul/1.12.3/consul_1.12.3_linux_amd64.zip &&\
unzip consul_1.12.3_linux_amd64.zip &&\
mv consul /usr/bin/
# Get LiteFS
RUN wget https://github.com/superfly/litefs/releases/download/v0.1.0/litefs-v0.1.0-linux-amd64.tar.gz -O - | tar -xzf -
@jwhear
jwhear / Dockerfile.fedora
Created July 28, 2022 14:09
LiteFS Dockerfile test (Fedora)
FROM fedora
RUN dnf install -y kmod fuse3 fuse3-libs fuse3-devel wget sqlite
RUN dnf install -y dnf-plugins-core && \
dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo && \
dnf -y install consul
#RUN modprobe fuse
# Get LiteFS
RUN wget https://github.com/superfly/litefs/releases/download/v0.1.0/litefs-v0.1.0-linux-amd64.tar.gz -O - | tar -xzf -
@jwhear
jwhear / Dockerfile.alpine
Last active July 28, 2022 14:08
LiteFS Dockerfile test
FROM alpine
RUN apk add fuse3 wget sqlite consul
# Get LiteFS
RUN wget https://github.com/superfly/litefs/releases/download/v0.1.0/litefs-v0.1.0-linux-amd64.tar.gz -O - | tar -xzf -
# Copy the repro script
COPY repro.sh .
@jwhear
jwhear / valgrind_gc.supp
Created August 14, 2019 23:00
Valgrind suppression D GC "leaks"
{
GC1
Memcheck:Cond
fun:_D2gc*
}
{
GC2
Memcheck:Value4
fun:_D2gc2gc*
}
@jwhear
jwhear / buffer.d
Created November 16, 2012 19:59
Derelict3 + GLFW3 Example
module buffer;
import derelict.opengl3.gl3;
class VertexArray
{
GLuint vao;
alias vao this;
this()
@jwhear
jwhear / bpbinstream1.js
Created January 12, 2012 20:51
JS Binary stream p1
Endianness = {
Little: 0,
Big: 1
};
BinaryStream = function(source){
this.source = source;
this.cursor = 0;
this.byteOrder = Endianness.Little;