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 / build.zig
Last active June 30, 2020 09:50
sdl-zig-demo (https://github.com/andrewrk/sdl-zig-demo) made to work with zig 0.6.0
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 09:33
Example of c-shared libhello.so
.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 April 30, 2020 20:42
Nimgobus example without package global variables
package main
import (
_ "image/png"
"time"
"github.com/adamstimb/nimgobus"
"github.com/hajimehoshi/ebiten"
)
@peterhellberg
peterhellberg / acnl.go
Last active April 17, 2020 11:50
Initial version of a parser for ACNL pattern files
package acnl
import (
"bytes"
"encoding/binary"
"image"
"image/color"
"io"
"io/ioutil"
)
@peterhellberg
peterhellberg / 46elks-sms-history.go
Created April 10, 2020 12:45
Retrieve SMS History from 46elks via their API as documented on https://46elks.com/docs/sms-history
package main
import (
"encoding/json"
"flag"
"fmt"
"net/http"
"net/url"
"os"
)
@peterhellberg
peterhellberg / bouncing-pixels.go
Created March 29, 2020 12:35
Drawing to the RPi (SenseHat) framebuffer over the network
package main
import (
"bufio"
"bytes"
"image/color"
"image/draw"
"net/http"
"time"
package main
import (
"flag"
"image"
"image/color"
"time"
"github.com/peterhellberg/gfx"
)
@peterhellberg
peterhellberg / gui-twisting-column.go
Created March 1, 2020 21:03
Twisting column using gui (and gfx) inspired by https://trasevol.dog/2018/01/24/di20/
package main
import (
"image"
"image/draw"
"time"
"github.com/peterhellberg/gfx"
"github.com/peterhellberg/gui"
)
@peterhellberg
peterhellberg / gfx-cubic-bezier-curve.go
Created March 1, 2020 19:06
Cubic Bezier Curve using gfx
package main
import "github.com/peterhellberg/gfx"
var (
p = gfx.PaletteAmmo8
dst = gfx.NewImage(256, 256, p[1])
p0 = gfx.V(16, 192)
p1 = gfx.V(32, 8)
p2 = gfx.V(192, 244)
@peterhellberg
peterhellberg / coders-of-the-caribbean.go
Last active January 31, 2020 20:11
Coders of the Caribbean in Go
package main
import (
"encoding/json"
"fmt"
"image"
"io"
"math"
"os"
"strings"