Skip to content

Instantly share code, notes, and snippets.

View r0mdau's full-sized avatar

Romain Dauby r0mdau

View GitHub Profile
@r0mdau
r0mdau / find-k8snode-interface.sh
Last active June 14, 2024 15:53
How to get tcpdump for containers inside Kubernetes pods
# find the kube node of the running pod, appear next to hostIP, and note containerID hash
kubectl get pod mypod -o json
# -> save hostIP
# -> save containerID
# connect to the node and find the pods unique network interface index inside it's container
docker exec containerID /bin/bash -c 'cat /sys/class/net/eth0/iflink'
# -> returns index
# locate the interface of the node
@r0mdau
r0mdau / gist:7e5100ff175acf954f05e5124c3d3b7d
Last active June 14, 2024 14:31
Match docker overlay directory with container name
df -hi
apt install jq
cd /var/lib/docker/overlay2/
find . -xdev -type f | cut -d "/" -f 2 | sort | uniq -c | sort -n
docker inspect $(docker ps -qa) | jq -r 'map([.Name, .GraphDriver.Data.MergedDir]) | .[] | "\(.[0])\t\(.[1])"'
docker ps
docker images
@r0mdau
r0mdau / HFS.md
Last active May 27, 2024 10:28
How to recover pictures and files from failed MacOS / HFS+ hard drive with Linux

How to recover pictures and files from failed MacOS / HFS+ hard drive with Linux

A couple months ago, a friend ask me to repair a failing macintosh.

It appears the hard drive has multiple failures from SMART anlysis.

Next reboot... Oh crap, the operating system does not start anymore. The drive contains 10 years of pictures to recover. A heart pinch :'(

Important thing to know, if (certainely) the disk is crypted and you don't know the principal user login password,

@r0mdau
r0mdau / README.md
Last active December 28, 2023 23:33
Rust Actix vs Rust Hyper vs Go fasthttp vs Go net/http httprouter

Load tests

Injector

wrk is the binary used as injector, always used with these options:

./wrk -t12 -c1000 -d15s http://127.0.0.1:8080/

Results

@r0mdau
r0mdau / script.sh
Created November 24, 2023 00:27
Bash scripts cheat reliability sheet
#!/bin/bash
# Enable debug mode
set -x
# Log function
log() {
echo "[INFO] $1"
}
@r0mdau
r0mdau / portForward.ps1
Created June 6, 2023 22:56
Windows port-forward to WSL2
# port forwarding
netsh interface portproxy add v4tov4 listenport=8090 listenaddress=0.0.0.0 connectport=8080 connectaddress=127.0.0.1
# allow in firewall
netsh advfirewall firewall add rule name=”WSL2 Forward Port 8090” dir=in action=allow protocol=TCP localport=8080
@r0mdau
r0mdau / checksdcard.py
Last active March 21, 2023 08:41
Python script to check raspberry pi SD card health
#!/usr/bin/python3
import os
def writeSomeBytesSucceed(datas):
filepath = "/sdCardTest.raw"
testpattern = bytes(datas)
writer = open(filepath, "wb", buffering=0)
writer.write(testpattern)
writer.close()
@r0mdau
r0mdau / autoresponse.txt
Created November 29, 2022 00:40
Career Advice Nobody Gave Me: Never ignore a recruiter
Thanks so much for reaching out. I'm always interested in hearing about what new and exciting opportunities are out there. As a software engineer I'm sure you can imagine that I get a very high volume of recruiters reaching out on LinkedIn. It is a wonderful position of privilege to be in and I'm thankful for it.
It does however mean that I don't have the time to hop on a call with everyone who reaches out. A lot of the time, incoming messages represent a very poor fit indeed.
I would love to continue the conversation, but before I do, I'd like to set around the level of seniority that you're looking for.
Can you send along the company name, a job description and, total compensation details for the role you're reaching out in reference to?
While I very much appreciate the fact that exceptionally talented and engaged recruiters reach out consistently, sorting serious and high quality opportunities from spam would be a full time job without an autoresponder.
@r0mdau
r0mdau / prom.md
Last active July 13, 2022 20:05
Prometheus cardinality stats

Prometheus cardinality stats queries:

sum(scrape_series_added) by (job)
sum(scrape_samples_scraped) by (job)
prometheus_tsdb_symbol_table_size_bytes

Doc:

scrape_series_added{job="", instance=""}: the approximate number of new series in this scrape.
@r0mdau
r0mdau / curl.sh
Created April 25, 2022 17:39
Get the CA for curl
# 1 get the cert
echo quit | openssl s_client -showcerts -servername server -connect example.com:443 > example.com.pem
# 2 use it in curl command to test it
curl --cacert example.com.pem https://example.com
# 3 add it to your certificates store (Debian)
sudo mv example.com.pem /usr/share/ca-certificates/example.com.crt
# 4 update the store
sudo dpkg-reconfigure ca-certificates
# 4 bis
sudo update-ca-certificates --fresh