Skip to content

Instantly share code, notes, and snippets.

View r0mdau's full-sized avatar

Romain Dauby r0mdau

View GitHub Profile
@r0mdau
r0mdau / readme.md
Created February 9, 2021 12:43 — forked from thomasdarimont/readme.md
Example for decoding a JWT Payload with your Shell (bash, zsh...)

Setup

Add this to your .profile, .bashrc, .zshrc...

decode_base64_url() {
  local len=$((${#1} % 4))
  local result="$1"
  if [ $len -eq 2 ]; then result="$1"'=='
  elif [ $len -eq 3 ]; then result="$1"'=' 
  fi
 echo "$result" | tr '_-' '/+' | openssl enc -d -base64
@r0mdau
r0mdau / kubeall.sh
Last active March 9, 2022 03:39
Kubectl daily shortcuts
#!/bin/bash
NAMES="$(kubectl api-resources --namespaced --verbs list -o name | grep -v events | tr '\n' ,)"
kubectl get "${NAMES:0:-1}" --show-kind
@r0mdau
r0mdau / test-nginx.conf
Last active January 20, 2021 05:21
Test Nginx conf quickly
server {
listen 80;
server_name localhost;
location ~ /watch {
default_type application/json;
if ($arg_device = desktop) {
return 200 '{"message": "Desktop found !"}';
@r0mdau
r0mdau / Dockerfile
Created June 10, 2020 07:06
Ugly Dockerfile for job interview
FROM debian:buster
LABEL name="php7"
LABEL author="test"
RUN apt-get update
RUN apt-get install -y apache2 php7.3
COPY . /app
COPY ./etc/custom.vhost /etc/apache2/sites-enabled/custom.vhost
@r0mdau
r0mdau / HFS.md
Last active March 15, 2024 11:50
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 / find-k8snode-interface.sh
Last active December 19, 2023 09:01
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 / 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 / backup.sh
Created September 7, 2019 17:47
Rsync backup
#!/bin/sh
if [ $(mount | grep -c /media/romain/disk) = 1 ]
then
SOURCE="/home/romain"
ACTUEL="/media/romain/disk/raupi/actuel"
BACKUP="/media/romain/disk/raupi/$(date +'%Y-%m-%d')"
mkdir -p "$BACKUP"
/usr/bin/rsync -av --stats --delete --backup --backup-dir="$BACKUP" "$SOURCE" "$ACTUEL"
rmdir --ignore-fail-on-non-empty $BACKUP
fi
@r0mdau
r0mdau / gist:7e5100ff175acf954f05e5124c3d3b7d
Last active May 3, 2023 16:13
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 / instructions.sh
Last active February 10, 2019 15:19
Cluster Kubernetes using virtualbox with Debian Stretch
##On the first VM
apt-get install -y apt-transport-https ca-certificates curl software-properties-common gnupg2
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
apt-get update
apt-cache madison docker-ce
apt-get install docker-ce=18.06.0~ce~3-0~debian
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main