Skip to content

Instantly share code, notes, and snippets.

@flrdv
flrdv / indigo-logo-mini.svg
Created July 24, 2025 16:37
Indigo logotype
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@flrdv
flrdv / go.mod
Last active March 17, 2024 12:23
CRUD using indigo
module github.com/Brom95/chi-crud
go 1.21
require (
github.com/indigo-web/chunkedbody v0.1.0 // indirect
github.com/indigo-web/indigo v0.15.9 // indirect
github.com/indigo-web/iter v0.1.0 // indirect
github.com/indigo-web/utils v0.6.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
@flrdv
flrdv / gist:d32971935516f566006f28c6c000a330
Created October 9, 2023 21:24
Benchmarks with old io.Copy
BenchmarkDecodeDigitsSpeed1e4-16 34405 34863 ns/op 286.84 MB/s 48 B/op 1 allocs/op
BenchmarkDecodeDigitsSpeed1e5-16 3474 344199 ns/op 290.53 MB/s 48 B/op 1 allocs/op
BenchmarkDecodeDigitsSpeed1e6-16 334 3560461 ns/op 280.86 MB/s 54 B/op 1 allocs/op
BenchmarkDecodeDigitsDefault1e4-16 36542 32941 ns/op 303.57 MB/s 48 B/op 1 allocs/op
BenchmarkDecodeDigitsDefault1e5-16 3073 386989 ns/op 258.41 MB/s 48 B/op 1 allocs/op
BenchmarkDecodeDigitsDefault1e6-16 310 3829224 ns/op 261.15 MB/s 56 B/op 1 allocs/op
BenchmarkDecodeDigitsCompress1e4-16 37678 31895 ns/op 313.53 MB/s 48 B/op 1 allocs/op
BenchmarkDecodeDigitsCompress1e5-16 3283 364022 ns/op 274.71 MB/s 48 B/
@flrdv
flrdv / gist:395a15a982cda3e43dc4f4833d3b2aac
Created October 9, 2023 12:16
Flate compressor comparing benchmarks
cpu: AMD Ryzen 7 5700X 8-Core Processor
Before patches:
BenchmarkDecodeDigitsSpeed1e4-16 32365 36650 ns/op 272.85 MB/s 81 B/op 3 allocs/op
BenchmarkDecodeDigitsSpeed1e5-16 3474 346724 ns/op 288.41 MB/s 106 B/op 4 allocs/op
BenchmarkDecodeDigitsSpeed1e6-16 332 3576404 ns/op 279.61 MB/s 435 B/op 18 allocs/op
BenchmarkDecodeDigitsDefault1e4-16 36774 32550 ns/op 307.22 MB/s 81 B/op 3 allocs/op
BenchmarkDecodeDigitsDefault1e5-16 2996 388516 ns/op 257.39 MB/s 92 B/op 3 allocs/op
BenchmarkDecodeDigitsDefault1e6-16 308 3847923 ns/op 259.88 MB/s 221 B/op 4 allocs/op
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@flrdv
flrdv / phl-algorithm.md
Last active December 14, 2023 21:24
An algorithm of automatically derived lifetimes

Pavlo's Hierarchical Lifetimes

Idea

GC is great from the point of view, that a programmer doesn't have to think about freeing variables - they do it by themselves. However, it brings performance penalties (and so-called "spikes" in terms of latency for web-applications). There are already Rust with its lifetimes, C++ with RAII and smart pointers, etc. However, they require programmer to process them manually. What about mixing both ways: compiler derives lifetimes automatically? Then it feels like a GC, but no actual GC is used.

Mechanism

Let's introduce the main point of the mechanism: hierarchy. It represents a structure of a type. Hierarchy consists of layers, where each layer is a container. For example: - Fundamental types are containers for primitives, that doesn't contain any other layesr. For example: int, float, bool, string, etc. - Complex types are containers, that may contain other types internally. For example: arrays, hashmaps, classes, etc. Each hierarchy may consist of at least

@flrdv
flrdv / main.go
Created October 23, 2022 20:17
Simple unidirectional generic linked list with implemented reversing
package main
import "fmt"
type Node[T any] struct {
payload T
next *Node[T]
}
func NewLList[T any](firstElem T) *Node[T] {
@flrdv
flrdv / matcher.go
Last active September 20, 2022 21:33
Dynamic path matcher
package main
import (
"context"
"errors"
"fmt"
context2 "github.com/fakefloordiv/indigo/internal/context"
"strconv"
"strings"
)
package prefixtree
const (
head = byte(0)
tail = byte(1)
)
type Leaf struct {
char byte
leaves []Leaf