This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { lib, fetchFromGitHub, cmake, llvmPackages_13, libxml2, zlib }: | |
| let inherit (llvmPackages_13) stdenv; | |
| in stdenv.mkDerivation rec { | |
| pname = "zig"; | |
| version = "0.9.1"; | |
| src = fetchFromGitHub { | |
| owner = "ziglang"; | |
| repo = pname; | |
| rev = version; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const std = @import("std"); | |
| fn BoolSerializer( | |
| comptime Context: type, | |
| comptime O: type, | |
| comptime E: type, | |
| comptime methods: struct { | |
| serializeBool: ?fn (Context, bool) E!O = null, | |
| }, | |
| ) type { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const std = @import("std"); | |
| pub fn main() !void { | |
| var gpa = std.heap.GeneralPurposeAllocator(.{}){}; | |
| const allocator = gpa.allocator(); | |
| defer { | |
| const deinit_status = gpa.deinit(); | |
| if (deinit_status == .leak) std.log.err("leaked memory", .{}); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const BoolIterator = struct { | |
| bools: []const bool, | |
| cursor: usize = 0, | |
| const Self = @This(); | |
| pub fn next(self: *Self) ?bool { | |
| if (self.cursor < self.bools.len) { | |
| const ret = self.bools[self.cursor]; | |
| self.cursor += 1; | |
| return ret; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const std = @import("std"); | |
| const testing = std.testing; | |
| const time = std.time; | |
| const Mutex = std.Thread.Mutex; | |
| var rand = std.rand.DefaultPrng.init(0); | |
| pub fn hi(store: *usize, wg_counter: *usize, m: *Mutex) void { | |
| // const id = std.Thread.getCurrentId(); | |
| // std.debug.print("hello from thread: {}\n", .{id}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "log" | |
| "os" | |
| "os/exec" | |
| "syscall" | |
| "github.com/pkg/errors" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const std = @import("std"); | |
| const mem = std.mem; | |
| const Allocator = mem.Allocator; | |
| const log = std.log; | |
| const Csv = struct { | |
| fields: std.ArrayList([][]const u8), | |
| backing: ?[]const u8, | |
| allocator: Allocator, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import "fmt" | |
| type InitFn[A any] func() A | |
| type IdentityFn[A any] func(x A) A | |
| type ReduceFn[A any, B any] func(acc A, cur B) A | |
| type Reducer[A any, B any] struct { | |
| Init InitFn[A] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as mats from "@thi.ng/matrices" // https://docs.thi.ng/umbrella/matrices/ | |
| import * as vecs from "@thi.ng/vectors" // https://docs.thi.ng/umbrella/vectors/ | |
| const x = 4 | |
| const y = 5 | |
| const vec = [x, y, 1] | |
| const dx = 1 | |
| const dy = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const randomString = (n) => { | |
| n = n ?? 8 | |
| const ret = []; | |
| for (let i = 0; i < n; i++) { | |
| const c = String.fromCharCode(Math.floor(Math.random()*26)+65) | |
| ret.push(c) | |
| } | |
| return ret.join("") | |
| } |