Skip to content

Instantly share code, notes, and snippets.

View duboisf's full-sized avatar

Fred Dubois duboisf

View GitHub Profile
@duboisf
duboisf / enable-scan-on-push.nu
Created May 27, 2025 19:58
Enable scan on push for all AWS ECR repositories that don't have it enabled, in nushell
aws ecr describe-repositories | from json | get repositories.repositoryName
| sort
| each { |repo|
let scanOnPush = (aws ecr batch-get-repository-scanning-configuration --repository-names $repo
| from json
| get scanningConfigurations
| first
| get scanOnPush
)
print $"Repository: ($repo), Scanning on push: ($scanOnPush)"
@duboisf
duboisf / coroutines.lua
Last active April 1, 2025 16:29
Example of running nvim coroutines sequentially and in parallel
-- Example of using coroutines with slow IO operations in Neovim.
-- It shows how to run coroutines sequentially and in "parallel".
-- The word "parallel" is in quotes because Lua coroutines are not actually
-- running in parallel, but the IO operations that they start are.
-- The coroutines are paused and resumed as the IO operations complete.
-- To run this example, put this file somewhere and do `:luafile path/to/coroutines.lua` in nvim.
local co = coroutine
vim.cmd "new"
@duboisf
duboisf / nu-get-all-s3-bucket-policies.md
Created February 3, 2025 17:15
Get all s3 bucket policies in an aws account using nushell

Get all s3 bucket policies in an aws account using nushell

In parallel! Saves output to a file so you can simply do open /tmp/bucket-policies.nuon after:

^aws s3api list-buckets
| from json
| get Buckets.Name
| par-each { |bucket|
 let policy = try {
@duboisf
duboisf / CreateGitopsFleetUser.md
Created January 21, 2025 15:48
Create a fleetmd api user with random password
fleetctl user create --name 'Gitops User' \
  --password "$(cat /dev/urandom | tr -cd '[:graph:]' | head -c 32)" \
  --email [email protected] \
  --api-only \
  --global-role admin
@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