Skip to content

Instantly share code, notes, and snippets.

View ldemailly's full-sized avatar

Laurent Demailly ldemailly

View GitHub Profile
@ldemailly
ldemailly / magicompress.sh
Last active May 9, 2025 01:18
Magic compression - best ratio ever ;-) 1:442604 for instance on a 22Mb binary to 52bytes !
#!/bin/sh
# Fun idea by https://github.com/ldemailly
set -e
filename="$1"
if [ -z "$filename" ]; then
echo "Usage: $0 <file|file.mc>" >&2
exit 1
fi
@ldemailly
ldemailly / tips.md
Created April 17, 2025 01:46
Tips for Managing Frustration with Unresponsive Forum Askers

Tips for Managing Frustration with Unresponsive Forum Askers

Dealing with users who ask questions but don't respond to follow-ups can be frustrating. Here are some strategies to manage this:

  • Lower Expectations: Accept that many askers will not follow up after their initial question for various reasons (solved it elsewhere, got busy, etc.). Closure on every thread is unlikely.

  • Don't Take it Personally: An asker's silence is typically about their own circumstances or priorities, not a reflection on the quality of your help or clarification questions.

  • Prioritize Clear Questions: Focus your time and expertise on questions that are well-defined from the start and where the asker appears engaged.

@ldemailly
ldemailly / gist:915e043323fa160562f121766990d9e3
Created August 17, 2024 21:38
fatal error: runtime: out of memory
fatal error: runtime: out of memory
runtime stack:
runtime.throw({0x4ef6d4?, 0x29ba8?})
runtime/panic.go:1023 +0x40 fp=0xffffc347a860 sp=0xffffc347a830 pc=0x4a790
runtime.sysMapOS(0x4000800000, 0xe8d4c00000)
runtime/mem_linux.go:167 +0x104 fp=0xffffc347a8a0 sp=0xffffc347a860 pc=0x2a0f4
runtime.sysMap(0x4000800000, 0xe8d4c00000, 0x9164e8?)
runtime/mem.go:155 +0x34 fp=0xffffc347a8c0 sp=0xffffc347a8a0 pc=0x29bb4
runtime.(*mheap).grow(0x9062a0, 0x746a529?)
runtime/mheap.go:1534 +0x278 fp=0xffffc347a940 sp=0xffffc347a8c0 pc=0x3d4a8
@ldemailly
ldemailly / main.go
Created July 18, 2024 23:58
minimal version that doesn't serve http request with `GOOS=wasip1 GOARCH=wasm go run -exec wasirun main.go`
package main
import (
"log"
"net/http"
"os"
"os/signal"
"github.com/stealthrocket/net/wasip1"
)
@ldemailly
ldemailly / info.md
Last active May 23, 2024 23:36
Import partial directories into another repo

using https://github.com/newren/git-filter-repo

mkdir import_tmp; cd import_tmp
wget https://raw.githubusercontent.com/newren/git-filter-repo/main/git-filter-repo # get the code
git clone https://github.com/fortio/fortio # the source repo
cd fortio/
python3 ../git-filter-repo --path fhttp --path fgrpc --path-rename 'fhttp:legacy/fhttp' --path-rename 'fgrpc:legacy/fgrpc'
ls legacy # works!
@ldemailly
ldemailly / gist:1e46ae1d9f3091f375bf91c6679074ca
Created March 20, 2024 16:54
Kubernetes Namespace cleanup script
#!/bin/bash
#
# NOTE: force deleting a namespace should be absolute last resort,
# you want instead to find which resource is holding up the namespace
# and clean that up (vs leaking resources)
#
# First check what is holding up the ns, if it's for instance:
# custom.metrics.k8s.io/v1beta1: the server is currently
# unable to handle the request
# Then:
#0 0.065 + dpkg --print-architecture
#0 0.092 + [ xppc64el != xs390x ]
#0 0.096 + apt-key add
#0 0.097 + curl -fsSL https://download.docker.com/linux/debian/gpg
#0 1.069 Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
#0 7.515 OK
#0 7.640 + dpkg --print-architecture
#0 7.663 + echo deb [arch=ppc64el] https://download.docker.com/linux/debian bullseye stable
#0 7.664 + apt-get -y update
#0 8.027 Hit:1 http://deb.debian.org/debian bookworm InRelease
@ldemailly
ldemailly / fortio.yaml
Last active September 17, 2021 16:23
fortio 3 layer with fan out of 2 both tcp and http
apiVersion: v1
kind: Namespace
metadata:
name: fortio
labels:
istio-injection: enabled
---
# Service "A" definition
apiVersion: v1
kind: Service
function newTable(t)
if not t then
t = {}
end
setmetatable(t, {__index = table})
return t
end
t = newTable({k1="v1", k2="v2", k3="v3",})
grpc_server_handled_total{grpc_code="OK",grpc_method="Check",grpc_service="istio.mixer.v1.Mixer",grpc_type="unary"} 230839
grpc_server_handled_total{grpc_code="OK",grpc_method="Report",grpc_service="istio.mixer.v1.Mixer",grpc_type="unary"} 1708
1000 ing->f2->f1 calls
grpc_server_handled_total{grpc_code="OK",grpc_method="Check",grpc_service="istio.mixer.v1.Mixer",grpc_type="unary"} 232862
grpc_server_handled_total{grpc_code="OK",grpc_method="Report",grpc_service="istio.mixer.v1.Mixer",grpc_type="unary"} 1768
60 reports
2023 checks (?)