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 / gfx-vintage.go
Created February 16, 2021 00:39
Effect inspired by the Youtube video “Recreating Vintage Computer Art with Processing” https://www.youtube.com/watch?v=LaarVR1AOvs
package main
import "github.com/peterhellberg/gfx"
const (
numLines = 16
frames = 300
)
func main() {
const std = @import("std");
const ray = @cImport({
@cInclude("raylib.h");
});
pub fn main() void {
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800;
@peterhellberg
peterhellberg / aoc-2020-01.zig
Last active January 13, 2021 16:30
Advent Of Code 2020 - 01
const std = @import("std");
const input = @embedFile("input");
const testing = std.testing;
const expect = testing.expect;
const print = std.debug.print;
pub fn main() anyerror!void {
var nums = try numberList(std.heap.page_allocator);
package main
import (
"math"
"time"
)
func main() {
delay := 16 * time.Millisecond
coreString := ".,-~:;=!*#$@"
@peterhellberg
peterhellberg / Lesson01.diff
Created September 11, 2020 10:05
zigNeHe Lesson01 patched to compile with current zig master https://github.com/mypalmike/zigNeHe
diff --git a/Lesson01/build.zig b/Lesson01/build.zig
index 7d1fc5b..83e4ee4 100644
--- a/Lesson01/build.zig
+++ b/Lesson01/build.zig
@@ -1,5 +1,5 @@
-const Builder = @import("std").build.Builder;
-const builtin = @import("builtin");
+const std = @import("std");
+const Builder = std.build.Builder;
package main
import (
"context"
"encoding/json"
"flag"
"os"
"time"
"github.com/c7/graphql"
@peterhellberg
peterhellberg / minimal.c
Created August 13, 2020 23:19
Trimmed down https://stackoverflow.com/a/59596600 to make it even more minimal
// based on https://stackoverflow.com/a/59596600
// Minimal Pure C code to create a window in Cocoa
// $ clang minimal.c -framework Cocoa -o minimal.app
#include <objc/runtime.h>
#include <objc/message.h>
#include <Carbon/Carbon.h>
#define cls objc_getClass
@peterhellberg
peterhellberg / webview-gui.go
Last active April 11, 2022 11:32
Webview GUI
package main
import (
"fmt"
"net"
"net/http"
"sync"
"text/template"
"github.com/zserge/webview"
@peterhellberg
peterhellberg / hellos.diff
Last active June 24, 2020 17:57
HellOS patched to compile using Zig 0.6.0 https://github.com/andrewrk/HellOS
diff --git a/hellos.zig b/hellos.zig
index 8563852..506f2c9 100644
--- a/hellos.zig
+++ b/hellos.zig
@@ -20,8 +20,9 @@ export var multiboot align(4) linksection(".multiboot") = MultiBoot{
export var stack_bytes: [16 * 1024]u8 align(16) linksection(".bss") = undefined;
const stack_bytes_slice = stack_bytes[0..];
-export nakedcc fn _start() noreturn {
- @newStackCall(stack_bytes_slice, kmain);
@peterhellberg
peterhellberg / ebiten-gfx-bookmark.go
Created June 6, 2020 20:53
Bookmark SDF rendered by Ebiten using gfx
package main
import (
"github.com/hajimehoshi/ebiten"
"github.com/peterhellberg/gfx"
)
type Game struct {
gfx.Vec
Image *gfx.Paletted