Skip to content

Instantly share code, notes, and snippets.

@neomantra
neomantra / yomamma.go
Created May 11, 2026 08:27
Mother's Day glass of BubbleTea
package main
import (
"fmt"
"math/rand"
"os"
"strings"
"time"
tea "charm.land/bubbletea/v2"
@neomantra
neomantra / go_mod_replace_version.sh
Created May 6, 2026 23:42
go mod replace version-timestamp-hash extractor
#!/bin/bash
#
# This script is used to generate a version string for the go.mod replace directive.
# This is of the format version-timestamp-hash, where version is the current version of the module,
# timestamp is the current time in UTC, and hash is the short git hash of the current commit.
#
# This script emits the "version-timestamp-hash" based on the current git HEAD.
#
# If passed with an argument, that string is used as the version,
# otherwise "v0.0.0" is used as the default version.
@neomantra
neomantra / PERF_NOTES.md
Created April 30, 2026 23:47
PIXterm Performance Engineering

Last night we was my first time doing LLM-based performance engineering, and wow what fun! I token-maxxed $20 of Codex 5.5, then wrapped up with Opus 4.7, along with Gemini for some code reivew.

After six hours, I and a 165x improvement of PIXterm! What follow is the performance log we kept.


Performance Notes

2026-04-30: Baseline vs v1.3.2

@neomantra
neomantra / request_to_curl.go
Created February 17, 2026 16:29
convert HTTPRequest to curl invocation
package curl
import (
"bytes"
"fmt"
"io"
"net/http"
"strconv"
"strings"
"unicode/utf8"
@neomantra
neomantra / top_exch_by_volume.sql
Last active September 6, 2025 01:36
Find exchange with top volume for each ticker with DataBento, dbn-go, and DuckDB
# within DuckDB run these commands
# load the parquet ohlcv files, which start with syms
CREATE TABLE ohlcvs AS SELECT * FROM './syms*.parquet';
# load the publishers parquet
CREATE TABLE publishers AS SELECT * FROM './publishers.parquet';
# query for the top publisher_id for each date,ticker
# QUALIFY is DuckDB dialect
SELECT date(ts_event),symbol,volume,close,P.dataset FROM ohlcvs O
events {
worker_connections 4096; ## Default: 1024
}
http {
# DEBUG:
map $uri $proxy_uri_base {
"~/crypto-proxy/(?<proxy_base>[^/]*)" $proxy_base;
default $uri;
}
@neomantra
neomantra / grafana-pdc.nomad.tpl
Last active July 12, 2024 19:44
pdc-agent with HashiCorp Nomad
# Grafana PDC -- private network tunnel
# This is templated by Terraform templatefile()
# https://grafana.com/docs/grafana-cloud/connect-externally-hosted/private-data-source-connect/configure-pdc/
job "grafana-pdc" {
region = "global"
datacenters = ["${NOMAD_DATACENTER}"]
namespace = "${NOMAD_NAMESPACE}"
type = "service"
@neomantra
neomantra / compressed_reader_writer.go
Created May 28, 2024 20:14
Compression wrappers for io.Reader and io.Writer
// Copyright (c) 2024 Neomantra BV
//
// Opinionated Reader/Writer wrappers
package nmio
import (
"compress/gzip"
"io"
"os"
@neomantra
neomantra / directory.go
Created May 21, 2024 22:45
VerifyDirectoryExists
func VerifyDirectoryExists(dirPath string) error {
if fileInfo, err := os.Stat(dirPath); err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("directory '%s' does not exist", dirPath)
} else {
return fmt.Errorf("error filestat on '%s': %w", dirPath, err)
}
} else if !fileInfo.IsDir() {
return fmt.Errorf("'%s' exists but is not a directory", dirPath)
}
@neomantra
neomantra / pointerValueMap.go
Created March 31, 2023 13:31
NewPointerValueMap converts a map[string]*T to a map[string]T, omitting nil pointers.
// NewPointerValueMap converts a map[string]*T to a map[string]T, omitting nil pointers.
func NewPointerValueMap[K comparable, V any](src map[K]*V) map[K]V {
dst := make(map[K]V)
for k, ptr := range src {
if ptr != nil {
dst[k] = *ptr
}
}
return dst
}