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 / redis_connection_string.go
Created April 29, 2014 21:47
Parsing a Redis connection string for use with go-workers
package main
import (
"fmt"
"net/url"
"strings"
)
func main() {
s := "redis://username:password@my.host:6389/4?pool=25&process=2"
@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"
package main
import "github.com/peterhellberg/gfx"
const w, h = 16, 16
const ramp = " .:-=+*#%@"
func main() {
m := gfx.NewGray(gfx.IR(0, 0, w, h))
@peterhellberg
peterhellberg / gfx-tinykaboom.go
Created January 28, 2019 16:16
tinykaboom with gfx
package main
import (
"image"
"image/color"
"math"
"github.com/peterhellberg/gfx"
)
@peterhellberg
peterhellberg / tibber-subscription.go
Created January 5, 2022 19:41
Tibber GraphQL Subscription from Go client
package main
import (
"encoding/json"
"flag"
"log"
"os"
"github.com/hasura/go-graphql-client"
)
package main
import (
"context"
"encoding/json"
"flag"
"os"
"time"
"github.com/c7/graphql"
@peterhellberg
peterhellberg / main.zig
Created November 19, 2021 14:13
WASM-4 in Zig!
const w4 = @import("wasm4.zig");
var sound = Sound{
.frequency = 255,
.duration = 10,
.volume = 2,
.flags = 0b1010,
};
const State = struct {
@peterhellberg
peterhellberg / gfx-kickstart-insert-floppy.go
Last active April 16, 2021 14:53
Renderer for an answer to "Why was the Kickstart 1.x “Insert floppy” graphic so bad?" https://retrocomputing.stackexchange.com/a/13940
package main
import (
"image"
"image/draw"
"github.com/peterhellberg/gfx"
)
const width, height = 320, 200
@peterhellberg
peterhellberg / g16.go
Created November 12, 2018 18:51
16 bit gray scale image in Go
package main
import (
"image"
"image/color"
"image/png"
"os"
)
func main() {
@peterhellberg
peterhellberg / ebiten-gfx-noise-flow-field.go
Created February 19, 2021 22:36
Noise flow field using Ebiten and GFX
package main
import (
"image"
"github.com/hajimehoshi/ebiten/v2"
"github.com/peterhellberg/gfx"
)
func main() {