Skip to content

Instantly share code, notes, and snippets.

View peterhellberg's full-sized avatar
💙
Coding Go and Zig

Peter Hellberg peterhellberg

💙
Coding Go and Zig
View GitHub Profile
@peterhellberg
peterhellberg / mmmm-logo.zig
Last active May 13, 2026 19:32
NES MMMM logo display with shimmer palette animation using https://github.com/kassane/zig-mos-bootstrap
//! NES MMMM logo display with shimmer palette animation.
const neslib = @import("neslib");
/// Nametable address for tile at column `col`, row `row` on nametable A ($2000).
fn ntadr(col: u8, row: u8) u16 {
return 0x2000 | (@as(u16, row) << 5) | col;
}
/// 16×16 tile map for the mark, anchored at (logo_col, logo_row).
/// Generated from mmmm-mark.chr (CHR plane 0 only).
@peterhellberg
peterhellberg / virtual-screen-size-in-raylib.zig
Created May 1, 2026 20:02
Virtual screen size in Raylib-Zig
const rl = @import("raylib");
const base = .{
.scale = 10,
.width = 160,
.height = 90,
};
const screen = .{
.width = base.width * base.scale,
@peterhellberg
peterhellberg / alpine.sh
Created April 17, 2026 22:22
Run script for my alpine VM created with https://github.com/keygenqt/skill-qemu-alpine
#!/usr/bin/env sh
set -eu
PORT="2224"
SCRIPT="$0"
while [ -L "$SCRIPT" ]; do
DIR="$(cd -P "$(dirname "$SCRIPT")" && pwd)"
SCRIPT="$(readlink "$SCRIPT")"
@peterhellberg
peterhellberg / 4bpp-to-png.go
Created March 16, 2026 22:02
Conversion between .4bpp to .png and vice versa
package main
import (
"fmt"
"image"
"image/color"
"image/png"
"io"
"os"
)
@peterhellberg
peterhellberg / WASMCarts_in_Zig.md
Last active March 16, 2026 22:12
WASMCarts in Zig

WASMCarts in Zig

I just found out about the in development fantasy console

https://github.com/pgattic/wasm-experiment

Since I'm on Pop_OS! which is currently based on 24.04 I need to install a newer version of cmake than what is in the default repos:

@peterhellberg
peterhellberg / web.c
Created March 3, 2026 20:26
Very basic web server in C
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <unistd.h>
@peterhellberg
peterhellberg / SLIDES.md
Created February 27, 2026 12:55
Slides: Durable Execution with Temporal
date 2026-02-27
author Peter Hellberg 🌿
paging [page %d / %d]
theme ../../../.slides/theme.json

Building Reliable Workflows

________________________________________________
@peterhellberg
peterhellberg / docker-compose.yml
Created February 26, 2026 07:35
MMMM Valheim Server
services:
valheim:
image: ghcr.io/lloesche/valheim-server
container_name: mmmm-valheim-server
cap_add:
- sys_nice
volumes:
- ./config:/config
- ./data:/opt/valheim
ports:
@peterhellberg
peterhellberg / install-zig.sh
Created February 20, 2026 08:10
Basic install script for Zig tarballs, that symlinks ~/.local/bin/zig-<version> to the downloaded and extracted zig binary.
#!/usr/bin/env bash
set -euo pipefail
# ----------------------------
# Check arguments
# ----------------------------
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <zig-version>"
echo "Example: $0 0.15.2"
CC ?= zig cc
CFLAGS ?= -std=c11 -Wall -Wextra `sdl2-config --cflags`
LDFLAGS ?= `sdl2-config --libs`
TARGET = sdl-minimal
all: $(TARGET)
$(TARGET): sdl-minimal.c
$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)