Skip to content

Instantly share code, notes, and snippets.

View andrewrk's full-sized avatar

Andrew Kelley andrewrk

View GitHub Profile
@andrewrk
andrewrk / 0example.zig
Created March 13, 2024 00:24
wait4 maxrss includes parent memory, why?
const std = @import("std");
const assert = std.debug.assert;
const expect = std.testing.expect;
pub fn main() !void {
const big = try std.heap.page_allocator.alloc(u8, 2 * 1024 * 1024 * 1024);
_ = big;
var child = std.ChildProcess.init(&.{"/usr/bin/env"}, std.heap.page_allocator);
child.stdin_behavior = .Ignore;
@andrewrk
andrewrk / instructions.ps1
Last active April 1, 2024 00:17
instructions to set up a runner
# Create a folder under the drive root
mkdir actions-runner; cd actions-runner
# Download the latest runner package
Invoke-WebRequest -Uri https://github.com/actions/runner/releases/download/v2.311.0/actions-runner-win-arm64-2.311.0.zip -OutFile actions-runner-win-arm64-2.311.0.zip
# Optional: Validate the hash
@andrewrk
andrewrk / bar.zig
Created December 19, 2023 00:26
demo of specifying different target CPU features per module. context: https://github.com/ziglang/zig/pull/18160
pub fn add(a: i32, b: i32) i32 {
return a + b;
}
@andrewrk
andrewrk / main.zig
Created December 1, 2023 21:40
advent of code 2023 day 1 part 1 in zig
const std = @import("std");
const example =
\\1abc2
\\pqr3stu8vwx
\\a1b2c3d4e5f
\\treb7uchet
;
pub fn main() !void {
@andrewrk
andrewrk / build.zig
Last active September 30, 2023 19:01
zig project with the main function being in C
const std = @import("std");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
@andrewrk
andrewrk / README.md
Created August 28, 2023 19:00
exfiltrate groove basin database to a JSON file
  1. drop db2json.js into your groovebasin instance
  2. stop your groove basin instance so that it does not write to the db while you are dumping its data
  3. node db2json.js (use the same node.js version as groove basin is using, and it also wants to use the same leveldown dependency you already have installed). It hard-codes the input as groovebasin.db.
  4. groovebasin.db.json is created which is 100% of the information from the database, in JSON format. It is one giant map of every key-value pair.
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFv8SrUBEADCku6WktTc1g+iyE9ZCtMv4kWqSHyQxFaEV8V5J2EAkjAzgr6w
NLmHGmNmXm8EzCWnwn/KfHJCeXTcgma/FtIF7hJfWB0xktA7WENUVc3qtT0cY9z3
9jh6J3TW3m9hcN7szSyEqGvPMVCvd5pERZXfof9OaRqtNak3GBOcklHYrVJ0KCtA
quR0t9NYrdOQikmBy4c9GaDsq/6H39LPuuj/vm7M+MHrw5dlKh+HPeUP9jMbFoXU
ohz97RSy8T2lUQDQx1EisAJNvdpU3mzAlWy2pEH+pKCBs5L0vPV/tvH1J5Pd489s
7VcdM9AolIuHvV0qCDAG7fcWujV5R5w48vznvfi6R3DN8O2iVrYdOWn2Bm60HdGm
XxGQswb6/MfThpFzQUNQpvnXxdbt2vefUTmM4suid6ki/jLfsiY1rqcNdEcriYFx
J6ma4SvZOB7OB2DG9bjWSItDIa2HqW37o//FYoFHJO0L+v5qjemYx5QrpL2wCpnY
@andrewrk
andrewrk / other-compiler_rt.zig.diff
Last active June 20, 2023 00:01
compiler_rt hacks for building musl libc.so with less symbol junk
--- a/lib/compiler_rt.zig
+++ b/lib/compiler_rt.zig
@@ -180,58 +180,58 @@ comptime {
_ = @import("compiler_rt/multc3.zig");
_ = @import("compiler_rt/divc3.zig");
- _ = @import("compiler_rt/divhc3.zig");
+ //_ = @import("compiler_rt/divhc3.zig");
_ = @import("compiler_rt/divsc3.zig");
_ = @import("compiler_rt/divdc3.zig");
@andrewrk
andrewrk / build.zig
Created February 20, 2023 16:20
sprinkling a little zig into a C project to help with debugging
const std = @import("std");
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard optimization options allow the person running `zig build` to select
@andrewrk
andrewrk / bootloader.zig
Created February 4, 2023 21:42
example of embedding a generated executable inside another one
pub export fn _start() void {}