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 / pro-prisundersokning.go
Last active February 19, 2024 08:25
Conversion of the "PRO Prisundersökning" from XLSX to CSV, JSON,NDJSON
package main
import (
"encoding/csv"
"encoding/json"
"flag"
"fmt"
"io"
"net/http"
"os"
@peterhellberg
peterhellberg / static_embed.go
Last active May 10, 2023 07:35
Embed and serve `static/*` on the root of your web server, using `embed`, `io/fs` and `net/http`
package main
import (
"embed"
"io/fs"
"net/http"
)
//go:embed static/*
var staticEmbed embed.FS
@peterhellberg
peterhellberg / tailget.sh
Created April 21, 2023 05:51
Taildrop: Receive file into temporary directory, change ownership, move to target directory
#!/usr/bin/env bash
user=peter
group=peter
target=/home/$user/Downloads/Taildrop/
tmpdir=$(mktemp -d '/tmp/taildrop.XXXXXX' 2>/dev/null || mktemp -d -t 'taildrop')
if [ -z "$tmpdir" ]
then
echo "Could not create temporary directory"
else
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char **argv)
{
FILE *afile = NULL;
FILE *bfile = NULL;
unsigned char *bbuffer = NULL;
@peterhellberg
peterhellberg / server.go.plush
Created January 11, 2023 16:08
Oto template which include otohttp inline instead of importing it.
// Code generated by oto; DO NOT EDIT.
package <%= def.PackageName %>
import (
"compress/gzip"
"context"
"encoding/json"
"fmt"
"io"
@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"
)
@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 / alacritty.yml
Last active April 23, 2023 09:58
Alacritty configuration with Jellybeans colorscheme, and ⌘↵ to ToggleSimpleFullscreen
# Configuration for Alacritty, the GPU enhanced terminal emulator.
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty itself.
env:
# TERM variable
#
# This value is used to set the `$TERM` environment variable for
# each instance of Alacritty. If it is not present, alacritty will
@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 / 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() {