Skip to content

Instantly share code, notes, and snippets.

View DeedleFake's full-sized avatar

DeedleFake

View GitHub Profile
@DeedleFake
DeedleFake / benchstat.txt
Created April 4, 2025 15:47
`io.Reader` vs. `iter.Seq2` vs. `iter.Pull()`
goos: linux
goarch: amd64
pkg: seqread
cpu: AMD Ryzen 9 3900X 12-Core Processor
│ simple.txt │ push.txt │ pull.txt │
│ sec/op │ sec/op vs base │ sec/op vs base │
Read-24 245.9n ± 1% 246.2n ± 2% ~ (p=0.725 n=10) 1137.0n ± 2% +362.29% (p=0.000 n=10)
│ simple.txt │ push.txt │ pull.txt │
@DeedleFake
DeedleFake / test.ex
Last active September 29, 2024 03:18
Simple GenServer that can coordinate work to a single duplicate of itself across a cluster.
defmodule Test do
use GenServer
require Logger
def start_link([]) do
GenServer.start_link(__MODULE__, [])
end
def init([]) do
@DeedleFake
DeedleFake / README.md
Last active September 2, 2024 20:56
Benchmarks of pull and push iterators in Go.

A simple benchmark comparing push and pull iterators to each other and also comparing them to themselves with and without PGO.

Results

goos: linux
goarch: amd64
pkg: test
cpu: AMD Ryzen 9 3900X 12-Core Processor
        │ no-pgo.txt  │              pgo.txt               │
@DeedleFake
DeedleFake / example.go
Created August 23, 2024 22:09
Channel server example.
package example
type Queue[T any] struct {
push chan T
pop chan T
}
func NewQueue[T any](ctx context.Context) {
q := Queue{
push: make(chan T),
@DeedleFake
DeedleFake / iter_test.go
Created August 15, 2024 08:08
Very simple benchmark of the new Go 1.23 iterators.
package iter_test
import (
"bufio"
"io"
"iter"
"strings"
"testing"
)
@DeedleFake
DeedleFake / README.md
Last active May 30, 2024 14:43
Whisper Audio Transcription Livebook

Audio Transcription

Run in Livebook

A simple Livebook for doing audio-to-text transcription using OpenAI's Whisper model.

@DeedleFake
DeedleFake / README.md
Last active April 25, 2024 19:51
Livebook auth module for forwarded auth headers behind a reverse proxy.

This is an extremely simply identity provider module for Livebook when running Livebook behind a reverse proxy with forwarded authentication, such as when using Tailscale. For more information, see https://github.com/tailscale/tailscale/tree/main/cmd/nginx-auth and https://caddyserver.com/docs/caddyfile/directives/forward_auth#tailscale.

To use this, just stick webauth.exs in /app/user/extensions or, if using a Docker container for Livebook, stick it somewhere else and mount it into the Docker container via -v /path/to/webauth.exs:/app/user/extensions/webauth.exs:ro. Then, just set LIVEBOOK_IDENTITY_PROVIDER=custom:Webauth when running the Livebook server.

@DeedleFake
DeedleFake / README.md
Created April 18, 2024 21:51
Docker Configuration for Running Livebook in a Container with Tailscale as the Identity Provider

I had a very specific configuration I was trying to get working for personal usage. After a bunch of running in circles, this was the result. I figured I'd stick it somewhere public in case anyone else finds it useful.

@DeedleFake
DeedleFake / README.md
Last active April 26, 2024 18:45
Livebook Setup with livebook:// URL Support on Linux

A Quick Guide to Setting up Livebook with Support for livebook:// URLs on Linux

Note that the following steps are intended as a rough outline. They are exact steps to replicate my setup, but your setup might differ depending on, for example, using an init system other than systemd or various other factors. Adjust as necessary.

  1. Run docker volume create livebook-data and docker volume create livebook-config.
  2. Place the livebook.service file in $HOME/.config/systemd/user.
  3. Run systemctl --user enable --now livebook.service.
  4. Place the dev.livebook.Livebook.desktop file in $HOME/.local/share/applications.
  5. Place the dev.livebook.Livebook.svg file in $HOME/.local/share/icons/hicolor/scalable/apps.
@DeedleFake
DeedleFake / README.md
Created December 12, 2023 19:43
Go/Elixir NIF Experiment

Go/Elixir NIF Experiment

This was a quick little experiment to try to call Go code from Elixir. To try it out, simply run

$ go build -buildmode=c-shared -o nif-test.so
$ iex test.exs