Skip to content

Instantly share code, notes, and snippets.

View MasterQ32's full-sized avatar
Hacking on Dunstwolke

Felix Queißner MasterQ32

Hacking on Dunstwolke
View GitHub Profile
MasterQ32 / memory.h
Last active September 26, 2023 19:28
Useful C
View memory.h
#include <stdint.h>
#include <string.h>
// Usage:
// uint16_t value = read_u16_le(buffer + 3);
#define __builtin_bswap8(x) (x) // "hack"
#define int_little_to_native(_Value, _Size) (_Value)
MasterQ32 / dotfiles
Created September 25, 2023 11:40
basic dotfile manager
View dotfiles
#!/usr/bin/env bash
set -euo pipefail
which git sed cut 1>/dev/null
timestamp="$(date +'%Y-%m-%d %H:%M')"
MasterQ32 / ui-concept.zig
Last active December 16, 2022 17:12
Zig UI API Concept
View ui-concept.zig
//! xq @ UTC+2 (MasterQ32 @ GitHub) — gestern um 22:01 Uhr
//! more gui thoughts:
//! i stopped using tree structures for my UIs and return to flat, ordered lists. this made the implementations sinpler by magnitudes, and one could always build stuff like a 'container' widget which would make it hierarchical by nesting UIs.
//! right now, dunstwolke uses a immediate mode interface, which is now borked by a bugfix in stage2.
//! now i'm thinking about how to decouple styling, layout and logic of the ui. also i'm still not sure how to manage UI events. i really dislike the callback approach of wpf/qt/winforms/...
//! compared to callbacks, immediate mode interfaces are very convenient to program, so i wonder if i can use a similar interface for a retained guy, for example a pull interface:
//! gui.pushInput(.mouse_down);
MasterQ32 /
Last active August 2, 2022 11:12
Arm 32 Kernel Example
set -e
zig build-exe -target arm-freestanding-eabi -mcpu baseline -T linker.ld -fsingle-threaded -fno-omit-frame-pointer -O ReleaseFast --name kernel kernel.zig
llvm-objdump -dt kernel
llvm-objcopy -O binary kernel kernel.bin
# cp kernel.bin disk.img
MasterQ32 / bad.zig
Created July 14, 2022 12:51
Comptime String Interning
View bad.zig
const std = @import("std");
const input = @embedFile("input.txt");
export const capitalized = blk: {
var result: []const []const u8 = &.{};
var iter = std.mem.tokenize(u8, input, ",.\r\n ");
MasterQ32 / atomics.zig
Created February 27, 2022 14:37
Examples of why atomics are necessary
View atomics.zig
const std = @import("std");
var global: u32 = 0;
export fn normalStore(arg: u32) void {
global = arg;
export fn normalLoad() u32 {
return global;
MasterQ32 / zig-packages.json
Last active February 19, 2022 10:06
Mini zpm
View zig-packages.json
"ihex": {
"git": ""
"args": {
"git": ""
"parser-toolkit": {
"git": ""
MasterQ32 / Sdk.zig
Created June 14, 2021 19:14
View Sdk.zig
const std = @import("std");
const Pkg =;
const Step =;
const FileSource =;
const GeneratedFile =;
pub const Sdk = @This();
builder: *,
MasterQ32 / any.zig
Created April 23, 2021 08:45
std::any implementation in zig
View any.zig
const std = @import("std");
pub fn main() !void {
var allocator = std.heap.page_allocator;
var a = try Any.init(allocator, @as(u32, 10));
defer a.deinit();
var b = try Any.init(allocator, @as([]const u8, "Hello, World!"));
defer b.deinit();
MasterQ32 / linkerscript.zig
Created March 19, 2021 00:02
View linkerscript.zig
const std = @import("std");
/// The linker here is "preloaded" with all input object files / symbols.
/// After this function is run, the linker will resolve all symbol references
/// and print all unassigned symbols (\u2192 error)
pub fn link(l: * !void {
// Creates a new output section that will be loaded into the
// same address as its virtual address. It's also a (rx!w) section
const dot_text = l.createOutputSection(".text", .{