Skip to content

Instantly share code, notes, and snippets.

View duboisf's full-sized avatar

Fred Dubois duboisf

View GitHub Profile
@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
@duboisf
duboisf / README.md
Created January 12, 2024 15:48
Automate the approval of a bunch of GitHub pull requests

Sometimes in the course of your job you might need to approve a bunch of pull requests that were automatically created.

The gh cli is a handy tool to simplify this process.

In this example we'll approve all pull requests in the Foo org that request you as a reviewer and contains autoscaling:

for PR_URL in $(gh search prs org:Foo --review-requested @me --state open autoscaling --json url --jq ".[].url"); do
 echo $PR_URL
@duboisf
duboisf / README.md
Last active January 13, 2024 09:31
zscaler apparmor profiles for Pop!_OS 22.04 LTS

To install zscaler on Pop!_OS 22.04, download the connector from the admin zscaler site by clicking the Client Connector link on the sidebar, then clicking Client Connector App Store, New Releases, Linux and download 1.4.0.105.

Before installing, you must temporarily replace your /etc/os-release file:

cd /etc
sudo mv os-release os-release.old
sudo cat <<EOF >> os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
package main
import (
"fmt"
"os"
)
func forEachInRange(start, end int, title string, callback func(int)) {
if start > end {
fmt.Fprintf(os.Stderr, "start %q must be smaller than end %q", start, end)
@duboisf
duboisf / aws
Last active December 6, 2022 16:56
aws docker bash script
#!/bin/bash
# Use docker to run the aws cli.
# This bash script can be put anywhere on your $PATH.
# Inspired from https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-docker.html
AWS_CLI_VERSION=2.8.6
debug() {
if [[ -n ${AWS_CONTAINER_DEBUG} ]]; then