Skip to content

Instantly share code, notes, and snippets.

Avatar
💙
Coding Go

Peter Hellberg peterhellberg

💙
Coding Go
View GitHub Profile
@peterhellberg
peterhellberg / Lesson01.diff
Created Sep 11, 2020
zigNeHe Lesson01 patched to compile with current zig master https://github.com/mypalmike/zigNeHe
View Lesson01.diff
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;
View tibber-graphql-query.go
package main
import (
"context"
"encoding/json"
"flag"
"os"
"time"
"github.com/c7/graphql"
@peterhellberg
peterhellberg / minimal.c
Created Aug 13, 2020
Trimmed down https://stackoverflow.com/a/59596600 to make it even more minimal
View minimal.c
// 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
View webview-gui.go
package main
import (
"fmt"
"net"
"net/http"
"sync"
"text/template"
"github.com/zserge/webview"
@peterhellberg
peterhellberg / hellos.diff
Last active Jun 24, 2020
HellOS patched to compile using Zig 0.6.0 https://github.com/andrewrk/HellOS
View hellos.diff
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 Jun 6, 2020
Bookmark SDF rendered by Ebiten using gfx
View ebiten-gfx-bookmark.go
package main
import (
"github.com/hajimehoshi/ebiten"
"github.com/peterhellberg/gfx"
)
type Game struct {
gfx.Vec
Image *gfx.Paletted
@peterhellberg
peterhellberg / build.zig
Last active Jun 30, 2020
sdl-zig-demo (https://github.com/andrewrk/sdl-zig-demo) made to work with zig 0.6.0
View build.zig
const Builder = @import("std").build.Builder;
pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
const exe = b.addExecutable("sdl-zig-demo", "src/main.zig");
exe.setBuildMode(mode);
exe.linkSystemLibrary("SDL2");
exe.linkSystemLibrary("c");
exe.install();
@peterhellberg
peterhellberg / Makefile
Created May 12, 2020
Example of c-shared libhello.so
View Makefile
.PHONY: all build compile clean
all: build compile
build:
go build -buildmode=c-shared -o libhello.so libhello.go
compile:
cc -o hello hello.c libhello.so
clean:
@peterhellberg
peterhellberg / nimgobus-example.go
Last active Apr 30, 2020
Nimgobus example without package global variables
View nimgobus-example.go
package main
import (
_ "image/png"
"time"
"github.com/adamstimb/nimgobus"
"github.com/hajimehoshi/ebiten"
)
@peterhellberg
peterhellberg / acnl.go
Last active Apr 17, 2020
Initial version of a parser for ACNL pattern files
View acnl.go
package acnl
import (
"bytes"
"encoding/binary"
"image"
"image/color"
"io"
"io/ioutil"
)
You can’t perform that action at this time.