Skip to content

Instantly share code, notes, and snippets.

View duboisf's full-sized avatar

Fred Dubois duboisf

View GitHub Profile
@duboisf
duboisf / docker-multi-arch-linux.md
Created October 5, 2024 13:27
HOWTO configure docker buildx to be able to build multi-archi images in Linux

Multi-architecture docker builds on Linux

Install binfmt if ls /proc/sys/fs/binfmt_misc/qemu* returns nothing:

docker run --privileged --rm tonistiigi/binfmt --install all

Verify that it worked, you should see stuff by running ls /proc/sys/fs/binfmt_misc/qemu*

@duboisf
duboisf / diff-container-images.sh
Last active September 27, 2024 19:03
Bash script to diff 2 container images
#!/bin/bash
# This script diffs the content of two container images
# USAGE: ./diff-container-images.sh <registry>/<repo> <tag1> <tag2>
# strict mode
set -euo pipefail
registry_repo=$1
tag1=$2
@duboisf
duboisf / tcpdump.md
Last active July 5, 2024 20:33
Using tcpdump with kubectl and wireshark
mkfifo /tmp/pcap.fifo
# Note: DO NOT use the -it option with exec!
kubectl exec deploy/some-pod -c istio-proxy -- bash -c "sudo tcpdump -s0 -U -n -i eth0 -w - " > /tmp/pcap.fifo
wireshark -k -i /tmp/pcap.fifo
@duboisf
duboisf / README.md
Created May 13, 2024 17:39
Searching GitHub folders with rg

I keep tripping up because I forget to add --hidden and use * instead of **:

rg --hidden --glob='**/.github/**' <PATTERN>
@duboisf
duboisf / notifications.md
Created February 23, 2024 15:44
Desktop notifications from terminal

With the kitty terminal, you can send desktop notifications with the following (example taken from the kitty docs):

printf '\x1b]99;i=1:d=0;Hello world\x1b\\'
printf '\x1b]99;i=1:d=1:p=body;This is cool\x1b\\'

For details about how this works is here.

@duboisf
duboisf / README.md
Created February 23, 2024 02:11
Fix nerdfont moved codepoints

Small app to detect and show fixed Nerfont moved codepoints

I wrote versions in golang and rust.

With golang it was a walk in the park but I've writen a lot of go.

I just started learning rust and oh boy did I struggle 😅

nushell script to watch for changes

@duboisf
duboisf / aws-utils.nu
Created February 20, 2024 20:43
aws utils written in nu
export def --wrapped aws [...rest]: nothing -> list<any> {
if ($rest | last) == "help" {
^aws ...$rest
} else {
^aws --output json ...$rest | from json | get-first
}
}
export def "get-first" []: record -> any {
let input = $in
@duboisf
duboisf / get-machines-from-all-kube-clusters.md
Last active February 19, 2024 22:32
Get karpenter machines from all clusters #cli #oneliner #nushell #kubectl

Getting machines from all clusters in nushell

I'm migrating karpenter to version v0.32.x and I need to verify if there are some machines left that might not have been migrated to nodepools.

Note

I have a none context that I select to "turn off" kubectl. I need to filter it out. To create this context, I used the following command: kubectl config set-context none

let machines = ^kubectl config view
@duboisf
duboisf / nu-all-aws-vpcs-all-accounts-all-regions.md
Last active February 19, 2024 22:33
A nushell oneliner to list all AWS VPC, for all accounts, in all regions #shell #oneliner #nushell

Get all AWS VPCs, for all accounts, in all regions, in nushell

The cool thing about this script is that it uses par-each to run the aws commands in parallel and collecting the results. Do you know how hard that is to do in bash?!

Warning

This script assumes that you have 1 profile entry for each AWS account of the form <account alias>/aws-read-only. Adapt as needed.

aws configure list-profiles | grep aws-read-only | lines | par-each {|profile|
@duboisf
duboisf / upgrade_helm_manifest_api_version.sh
Last active January 19, 2024 19:35
Update deprecated kubernetes api version that's stored in a helm release that's stored in a secret
#!/bin/bash
# Strict mode
set -euo pipefail
if [ $# -ne 3 ]; then
echo "Usage: $0 <helm_release_name> <old_api_version> <new_api_version>"
exit 1
fi