Skip to content

Instantly share code, notes, and snippets.

@binarycraft007
binarycraft007 / mkfs_ubifs.zig
Created November 12, 2026 15:41
zig wrapper for mkfs_ubifs
const std = @import("std");
extern "c" fn mkfs_ubifs_main(argc: c_int, argv: [*]const [*:0]const u8) c_int;
extern "c" var optind: c_int;
const CompressMethod = enum {
lzo,
favor_lzo,
};
@binarycraft007
binarycraft007 / Zipper.zig
Created November 11, 2026 14:18
zig zip compression revived
/// Struct File allows for associating a file's contents with the corresponding path in the Zip file.
pub const File = struct {
name: []const u8,
content: []const u8,
};
/// Used to store any data from writing a file to the zip archive that's needed
/// when writing the corresponding central directory record.
pub const FileStore = struct {
compression: zip.CompressionMethod,
@binarycraft007
binarycraft007 / fuzz-clang-compatible-sancov.patch
Created November 10, 2026 11:51
fuzzer fix for support fuzzing C/C++ code for zig 0.17.0
diff --git a/lib/fuzzer.zig b/lib/fuzzer.zig
index bc40abe5..a0d9d2ca 100644
--- a/lib/fuzzer.zig
+++ b/lib/fuzzer.zig
@@ -55,6 +55,12 @@ fn bitsetUsizes(elems: usize) usize {
return @divCeil(elems, @bitSizeOf(usize));
}
+/// https://github.com/llvm/llvm-project/blob/6121df77a781d2e6f9a8e569aa45ccfffd6c7e0e/compiler-rt/lib/fuzzer/FuzzerTracePC.h#L122
+const PCTableEntry = extern struct {
@binarycraft007
binarycraft007 / build.zig
Created November 4, 2026 22:51
build musl 1.2.5 with zig
const std = @import("std");
const mem = std.mem;
const path = std.fs.path;
const Allocator = mem.Allocator;
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{
.default_target = .{ .os_tag = .linux },
});
const optimize = b.standardOptimizeOption(.{});
@binarycraft007
binarycraft007 / kbuild.zig
Created November 4, 2026 22:50
kbuild parser in zig
const std = @import("std");
pub const Operator = enum {
assign, // = or :=
append, // +=
};
pub const Condition = union(enum) {
always: void, // e.g. lib-y
config: []const u8, // e.g. CONFIG_CHCON in lib-$(CONFIG_CHCON)
@binarycraft007
binarycraft007 / Spoof Year 2038-1.0.user.js
Created August 24, 2026 08:26
A Tampermonkey user script to spoof year 2038
// ==UserScript==
// @name Spoof Year 2038
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Makes the browser think it's 2038
// @match *://*/*
// @run-at document-start
// @grant none
// ==/UserScript==
@binarycraft007
binarycraft007 / zest.md
Created April 14, 2026 17:13
zest architecture

Zest: Architecture & Design Philosophy

Zest (Zig-powered Embedded Systems Tool) is a modern, high-performance build system and distribution kit for embedded Linux. It aims to provide the flexibility of OpenWrt and the simplicity of Buildroot, while leveraging the safety and cross-compilation prowess of the Zig toolchain.

1. Core Vision

Traditional embedded build systems often suffer from "Makefile-hell" and global state issues. Zest replaces fragile shell scripting with a strictly typed, declarative build graph in Zig.

The goal is to move from "building a system" to "composing a system" from isolated, reproducible components.


@binarycraft007
binarycraft007 / PKGBUILD
Last active March 30, 2026 13:13
PKGBUILD for renode
# Maintainer: Elliot <elliot@example.com>
pkgname=renode
pkgver=1.16.1
pkgrel=1
pkgdesc="The Renode Framework"
arch=('x86_64' 'aarch64')
url="https://renode.io"
license=('MIT')
options=(!strip !debug)
depends=('dotnet-runtime-8.0' 'python' 'python-pip' 'screen' 'gcc')
@binarycraft007
binarycraft007 / ieltsbro.md
Created March 23, 2026 09:08
ieltsbro repackaging

Converting Windows Electron App to Linux aarch64

This document outlines the steps taken to convert the Windows version of the "雅思哥机考软件" (yasige) Electron application to run natively on a Linux aarch64 (ARM64) host.

Prerequisites

Ensure you have Node.js and npm installed on your Linux aarch64 system:

node -v
@binarycraft007
binarycraft007 / libbpf-zig-port-spec.md
Last active January 21, 2026 09:00
port libbpf to zig

libbpf to Zig Porting Specification

This document provides a comprehensive technical specification for reimplementing libbpf v1.0+ in Zig. It covers architecture, binary formats, algorithms, and implementation details derived from a deep code analysis.

1. Architecture & Layering

The library is organized into distinct, interdependent layers:

  1. sys (Syscalls): Strictly mirrors uapi/linux/bpf.h. No logic, just definitions and direct kernel calls.
  2. btf (Type System): Handles parsing and navigation of .BTF and .BTF.ext data.