Skip to content

Instantly share code, notes, and snippets.

View DeedleFake's full-sized avatar

DeedleFake

View GitHub Profile
@DeedleFake
DeedleFake / set.par
Last active December 2, 2025 20:02
String set implemented in Par.
type Set<a> = iterative box choice {
.add(a) => self,
.has(a) => (Bool) self,
.remove(a) => self,
}
dec Set.String : [List<String>] Set<String>
def Set.String = [list] do {
let list: List<(String) !> = list.begin.case {
.end! => .end!,
@DeedleFake
DeedleFake / fetch.par
Last active December 2, 2025 04:34
A wrapper around `Http.Fetch` that's a bit nicer for using in the Par playground.
dec Fetch : [String, String, List<(String) String>, String]
Result<Http.Error, (Nat, List<(String) String>) List<Result<Http.Error, String>>>
def Fetch = [method, url, headers, body] chan yield {
catch e => { yield <> .err e }
let try url = Url.FromString(url)
let req = (method, url, headers) Bytes.Reader(body)
let try (status, headers) body = Http.Fetch(req)
let headers = ToStringHeaders(headers)
let body = ToLines(type Http.Error)(body)
@DeedleFake
DeedleFake / README.md
Last active December 3, 2025 00:53
Towers of Hanoi solver in Par.
@DeedleFake
DeedleFake / convert.bash
Created July 10, 2025 20:33
A script to convert an MP4 to an upscaled WebP file. Script was originally generated by Grok 4 and then tweaked slightly.
#!/bin/bash
# Prerequisites:
# - ffmpeg and ffprobe installed (for video processing).
# - upscayl-ncsnn installed (for upscaling).
# Ensure it's in your PATH or adjust the command below.
# - Models optionally downloaded into a 'models' directory in the current working directory (or adjust -m option).
#
# Usage: ./script.sh input.mp4 output.webp [scale] [model]
# - scale: Upscale factor (default: 4, can be 2, 3, or 4).
@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.