Skip to content

Instantly share code, notes, and snippets.

View DeedleFake's full-sized avatar

DeedleFake

View GitHub Profile
@DeedleFake
DeedleFake / go.mod
Last active July 31, 2023 19:02
A simple attempt at implementing iterators using golang/go#61405.
module test
go 1.21
@DeedleFake
DeedleFake / decoman-fix.patch
Created February 24, 2023 21:40
drawterm Wayland backend decoration manager fix
diff --git a/gui-wl/wl-cb.c b/gui-wl/wl-cb.c
index 2e07bf8..514aaf7 100644
--- a/gui-wl/wl-cb.c
+++ b/gui-wl/wl-cb.c
@@ -698,7 +698,7 @@ wlsetcb(Wlwin *wl)
wl_display_roundtrip(wl->display);
wl->xkb_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
- if(wl->shm == nil || wl->compositor == nil || wl->xdg_wm_base == nil || wl->seat == nil || wl->decoman == nil || wl->primsel == nil)
+ if(wl->shm == nil || wl->compositor == nil || wl->xdg_wm_base == nil || wl->seat == nil || wl->primsel == nil)
@DeedleFake
DeedleFake / README.md
Last active February 15, 2023 01:50
`binary-trees` using `GOEXPERIMENT=arenas`.

binary-trees benchmark

This gist implements the binary-trees benchmark from the Language Shootout Game using the arenas GOEXPERIMENT in Go 1.20. trees.go is based on the Go #6 entry, but uses a manual free list instead of sync.Pool. To enable arena support, just set GOEXPERIMENT=arenas.

Results on my Machine

Stats

@DeedleFake
DeedleFake / README.md
Last active February 2, 2023 21:47
A simple `go test` wrapper around the `binary-trees` benchmark.

binary-trees benchmark

This gist runs the binary-trees benchmark from the Language Shootout Game as a go test benchmark. trees.go is copied verbatim from the Go #6 entry.

To run the benchmark, just use go test -bench='.*'. If you would like to test PGO, which was the original intention of this code, you can use the following series of commands

$ go test -cpuprofile default.pgo -bench='.*'
$ go test -pgo auto -bench='.*'
@DeedleFake
DeedleFake / sieve.c
Created January 5, 2023 21:38
A Plan 9 C translation of the Go channel-based concurrent prime sieve, translated with the help of Chat GPT.
#include <u.h>
#include <libc.h>
#include <thread.h>
typedef struct FilterArg {
Channel *in;
Channel *out;
int prime;
} FilterArg;
@DeedleFake
DeedleFake / unwrap.go
Created November 25, 2022 06:45
An attempt at generalizing the `Unwrap()` pattern in Go.
package main
import (
"errors"
"fmt"
"io/fs"
)
type Unwrapper[T any] interface {
Unwrap() T
@DeedleFake
DeedleFake / future.go
Last active October 27, 2022 17:54
Am idea for a Go futures API.
package sync
import (
"fmt"
"sync"
"time"
)
type Future[T any] struct {
done chan struct{}
@DeedleFake
DeedleFake / go.mod
Created September 22, 2022 04:50
A little Bubbletea experiment to workaround terminal resizing issues on Windows.
module test
go 1.19
require (
github.com/charmbracelet/bubbletea v0.22.1
github.com/charmbracelet/lipgloss v0.6.0
golang.org/x/term v0.0.0-20220919170432-7a66f970e087
)
@DeedleFake
DeedleFake / example.go
Last active May 31, 2022 19:57
A horrible implementation of a non-allocating union type for Go. Don't use it. It has bugs.
package main
import (
"fmt"
"strconv"
"unsafe"
)
type Event interface {
etype() etype
@DeedleFake
DeedleFake / go.mod
Last active April 19, 2022 20:03
A Go reimplementation of ThePrimeagen's Rust string processing example.
module points
go 1.18