Skip to content

Instantly share code, notes, and snippets.

View peterhellberg's full-sized avatar
💙
Coding Go

Peter Hellberg peterhellberg

💙
Coding Go
View GitHub Profile
@peterhellberg
peterhellberg / Makefile
Last active August 15, 2025 14:05
Example of behavioral change when using `virtual` in C++
.PHONY: all
all: build run
CXX := $(or $(CXX),zig c++)
.PHONY: build
build:
${CXX} greeter.cpp -o greeter
${CXX} virtual.cpp -o virtual
@peterhellberg
peterhellberg / How_to_move_Valheim_world.html
Created July 12, 2025 10:36
Example of using Markdown support in Caddy using its `templates` directive.
{{ $doc := `
# How to move a Valheim world save
If you need to move a world save from one server to another,
or from your local machine to a server,
this shouldn’t be too painful ;)
## The default location that Valheim saves world files is:
- Windows: %USERPROFILE%/AppData/LocalLow/IronGate/Valheim/worlds/
const std = @import("std");
const mem = std.mem;
const sin = std.math.sin;
const cos = std.math.cos;
const signedRemainder = std.zig.c_translation.signedRemainder;
pub const object_size = std.zig.c_builtins.__builtin_object_size;
pub const memset_chk = std.zig.c_builtins.__builtin___memset_chk;
pub const useconds_t = c_uint;
@peterhellberg
peterhellberg / document.md
Last active May 22, 2025 16:49
Using the Typst package for cmarker to convert Markdown into PDF/SVG via `typst compile`

We can write Markdown!

const std = @import("std");
const Reset = "\x1b[0;0m";
const Red = "\x1b[0;31m";
const Green = "\x1b[0;32m";
const Black = "\x1b[0;30m";
const Who = enum {
N,
O,
@peterhellberg
peterhellberg / docs_step.zig
Created March 4, 2025 09:02
Zig build step for emitting docs by calling `zig build docs`
const docs_step = b.step("docs", "Emit docs");
const docs_install = b.addInstallDirectory(.{
.install_dir = .prefix,
.install_subdir = "docs",
.source_dir = exe.getEmittedDocs(),
});
docs_step.dependOn(&docs_install.step);
function dl(n) {
setTimeout(function(){
document.querySelector('span[class^="Notification-module_close__"]').click();
}, 500);
var more = document.querySelectorAll('div[class^="Dropdown-module_container__"]');
more[n].click();
more[n].querySelector('div[id^="DOWNLOAD_AND_TRANSFER_ACTION_"]').click();
more[n].querySelector('label[class^="RadioButton-module_radio_container__"] input').click();
@peterhellberg
peterhellberg / ff-emu.go
Last active February 6, 2025 10:57
Rudimentary emulator for Firefly Zero written in Go
package main
import (
"context"
"flag"
"fmt"
"image"
"image/color"
"image/draw"
"io"
@peterhellberg
peterhellberg / unzipzstd.go
Last active February 5, 2025 15:11
A quick and dirty decompressor for Firefly Zero carts (Which are Zip files compressed using ZSTD) - https://docs.fireflyzero.com/internal/formats/#rom
package main
import (
"archive/zip"
"flag"
"fmt"
"io"
"os"
"path/filepath"
"strings"
@peterhellberg
peterhellberg / imgur-assets-dl.go
Created February 5, 2025 11:19
Small script that downloads images I publish on Imgur to my own server
package main
import (
"errors"
"flag"
"fmt"
"io"
"net/http"
"os"
"path/filepath"