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 ( | |
"os" | |
"os/exec" | |
"reflect" | |
"runtime" | |
) | |
func main() { |
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
data: Data = undefined, | |
len: Length, | |
systems: Systems = .{}, | |
/// Run all systems for a single logical game update. | |
pub fn update(ecs: *EntityComponentSystem, dt: f64) void { | |
inline for (@typeInfo(Systems).Struct.fields) |field| { | |
@field(ecs.systems, field.name).run(&ecs.data, &ecs.len, dt); | |
} | |
} |
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 math | |
import random | |
from typing import List, Any, Dict, Union | |
random.seed(0xcafebabedeadbeef) # ensure reproducible results | |
# ---- infinite axis utility system ----- | |
# The framework which you'll only need to write once |
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
// How to write your very own MMO --- an introduction to multiplayer game design | |
// Copyright © 2023 Simon A. Nielsen Knights <[email protected]> | |
// SPDX-License-Identifier: AGPL-3.0-only | |
// | |
// This program is free software: you can redistribute it and/or modify | |
// it under the terms of the GNU Affero General Public License as | |
// published by the Free Software Foundation, either version 3 of the | |
// License, or (at your option) any later version. | |
// | |
// This program is distributed in the hope that it will be useful, |
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
Awesome stuff I cannot look at due to clean room design. | |
# Colour spaces | |
- https://github.com/nitrogenez/prism |
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 testing = std.testing; | |
const assert = std.debug.assert; | |
const Allocator = std.mem.Allocator; | |
const Table = struct { | |
/// Each row consists of `stride` number of columns of string indices. | |
rows: std.ArrayListUnmanaged(String) = .{}, |
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
// stack over time | |
// ,-------------, | |
var outputTable = Table.init(4, allocator); // ,-> | outputTable | | |
// | |-------------|---, | |
for (alerts.value.data.alerts) |a| { // | | outputTable | a | stack location of `r` | |
// | |-------------|---|---, | |
var r = [_][]u8{ // | | outputTable | a | r | stack location of the fields of `a` when placed in the array of slices passed to `r` -------, | |
// | |-------------|---|---|-------------------, | | |
a.labels.instance, // f | | outputTable | a | r | a.labels.instance | | | |
// |
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 build(b: *std.Build) void { | |
const target = b.standardTargetOptions(.{}); | |
const optimize = b.standardOptimizeOption(.{}); | |
const exe = b.addExecutable(.{ | |
.name = "hook", |
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
pub fn dispatch(arena: Allocator, cwd: Dir, context: Context, argv: []const [*:0]const u8, comptime hooks: Self) !void { | |
const basename = fs.path.basename(mem.span(argv[0])); | |
const command = Self.map.get(basename) orelse return error.UnknownCommand; | |
switch (command) { | |
inline else => |tag| { | |
const com = @field(hooks, @tagName(tag)); | |
const Fn = @TypeOf(com); | |
const info = @typeInfo(Fn).Fn; | |
var tuple: meta.ArgsTuple(Fn) = undefined; |
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 assert = std.debug.assert; | |
const Ast = std.zig.Ast; | |
pub fn main() !void { | |
var instance = std.heap.GeneralPurposeAllocator(.{}){}; | |
defer assert(instance.deinit() == .ok); | |
const gpa = instance.allocator(); |
NewerOlder