Skip to content

Instantly share code, notes, and snippets.

View sylr's full-sized avatar

Sylvain Rabot sylr

View GitHub Profile
@sylr
sylr / init.lua
Created October 30, 2026 10:24
Rex next/previous pane or tab
-- Load modules from this directory, wherever the server's working directory is.
local dir = debug.getinfo(1, "S").source:match("^@(.*/)") or "./"
package.path = dir .. "?.lua;" .. package.path
require("pane_or_tab")
rex.bind("cmd+[BracketRight]", "next_pane_or_tab")
rex.bind("cmd+[BracketLeft]", "previous_pane_or_tab")
@sylr
sylr / markdown.css
Last active October 14, 2026 06:32
Claude Code like github markdown
.markdown-body {
--cc-text: #c4c4c4;
/* regular text: grey-ish */
--cc-bright: #ffffff;
/* bold / headings */
--cc-lavender: rgb(177, 185, 249);
/* inline code, links */
--cc-dim: rgb(153, 153, 153);
/* bullets, quotes, secondary */
--cc-orange: rgb(215, 119, 87);
@sylr
sylr / repro_latency_test.go
Created April 5, 2026 15:38
NATS latency ramping up
package server
import (
"context"
"fmt"
"math"
"sort"
"sync"
"sync/atomic"
"testing"
{
description = "A Nix-flake-based Go 1.25 development environment";
inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2505";
nixpkgs-unstable.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1";
nur = {
url = "github:nix-community/NUR";
inputs.nixpkgs.follows = "nixpkgs";
@sylr
sylr / sub_slice_clone.go
Created March 25, 2025 19:31
Go sub slice cloning
package main
import (
"bytes"
"fmt"
"unsafe"
)
type Message struct {
buffer []byte
@sylr
sylr / cloudtrail2db.py
Created December 2, 2024 22:05
Convert cloudtrail json files from S3 to sqlite databa
import json
import sqlite3
import click
import re
import gzip
# Function to create the SQLite database and the necessary tables
def create_db(db_name: str) -> sqlite3.Connection:
conn = sqlite3.connect(db_name, autocommit=False, isolation_level="DEFERRED")
cursor = conn.cursor()
package bench
import (
"testing"
"time"
)
func BenchmarkMarshalBinary(b *testing.B) {
bs := make([]byte, 16*4)
@sylr
sylr / Makefile
Last active March 5, 2026 20:02
Build go-tools with latest versions
GO ?= go
export GITFLAGS='--filter=blob:none'
build: go.work
$(GO) build ./github.com/a-h/templ/cmd/templ
$(GO) build ./github.com/go-delve/delve/cmd/dlv
$(GO) build ./github.com/golangci/golangci-lint/cmd/golangci-lint
$(GO) build ./golang.org/x/tools/cmd/deadcode
$(GO) build ./golang.org/x/tools/gopls
@sylr
sylr / aoc-2023-day-01-1.sh
Created December 3, 2023 19:42
aoc-2023-day-01
echo "+/" $(sed -e 's/[^0-9]//g' -e 's/^\(.\)$/\1\1/' -e 's/^\(.\).*\(.\)$/\1\2/' ~/aoc-1.input) | ivy
# Convert X hours Y minutes to Z minutes
op a mins b = (0 60 decode a b)
# data hours minutes hours minutes ... etc
x = 0 53 1 32 0 53 1 6 1 9 0 41 1 3 1 1 1 2 2 17 0 46 1 36
# reduce
+/mins/((rho x)/2) 2 rho x
# hours