Skip to content

Instantly share code, notes, and snippets.

View mimizone's full-sized avatar

Jeremy Huylebroeck mimizone

  • San Francisco
  • 01:47 (UTC -07:00)
  • X @mimizone
View GitHub Profile
cp ~/.kube/config ~/.kube/config-backup
export KUBECONFIG=~/.kube/config:/path/cluster1:/path/cluster2
kubectl config view --flatten > all-in-one-kubeconfig.yaml
mv all-in-one-kubeconfig.yaml ~/.kube/config
kubectl config get-clusters
@mimizone
mimizone / listdiskids.sh
Created May 31, 2023 04:15
list disks by id
lsblk |awk 'NR==1{print $0" DEVICE-ID(S)"}NR>1{dev=$1;printf $0" ";system("find /dev/disk/by-id -lname \"*"dev"\" -printf \" %p\"");print "";}'|grep -v -E 'part|lvm'
@mimizone
mimizone / sh
Created May 26, 2023 04:49
compare the checksum of all files with the same name in 2 different folders
#!/bin/bash
CERROR='\033[0;31m' #Error color
COK='\033[0;32m' #Error color
NC='\033[0m' # No Color
IFS=$'\n'
offset=$(( ${#1} + 1))
fnames=`find ${1} -type file -not -path '*/.*'`

Keybase proof

I hereby claim:

  • I am mimizone on github.
  • I am mimizone (https://keybase.io/mimizone) on keybase.
  • I have a public key ASClrk7aDLM3ifkH9Ha3iT7bb0aHTvOJXkH8geGSIK4_nQo

To claim this, I am signing this object:

@mimizone
mimizone / rancher-upgrade
Last active April 25, 2019 20:28
simple backup/upgrade rancher
#!/bin/bash
CONTAINERNAME=rancher-server
NEWVERSION=v2.2.0
CURRENTVERSION=`docker inspect ${CONTAINERNAME} | jq --raw-output '.[]."Config"."Image"' | awk -F ':' '{print $2}'`
DATE=`date +%Y-%m-%d-%H-%M-%S`
function version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }
if ! version_gt $NEWVERSION $CURRENTVERSION; then
@mimizone
mimizone / sh
Created February 15, 2019 17:53
netstat without netstat
grep -v "rem_address" /proc/net/tcp | awk 'function hextodec(str,ret,n,i,k,c){
ret = 0
n = length(str)
for (i = 1; i <= n; i++) {
c = tolower(substr(str, i, 1))
k = index("123456789abcdef", c)
ret = ret * 16 + k
}
return ret
} {x=hextodec(substr($2,index($2,":")-2,2)); for (i=5; i>0; i-=2) x = x"."hextodec(substr($2,i,2))}{print x":"hextodec(substr($2,index($2,":")+1,4))}'
@mimizone
mimizone / cleanupitunes.sh
Last active November 12, 2018 21:43
cleanup duplicates in iTunes folder after consolidation crashed in the middle
#!/bin/bash
path=`pwd`
echo "processing $path"
echo "-------------------------------CHECKING FOLDERS-------------------------------"
# list the folders that are most likely duplicates
#remove " 1$", check a folder exists with that name, and delete
folders=`find . | egrep " 1$"`
while read -r f
@mimizone
mimizone / gitlab-runner.yaml
Created August 8, 2018 21:48
setup Gitlab runner namespace, service account and token for kubernetes
apiVersion: v1
kind: Namespace
metadata:
name: gitlab-managed-apps
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: gitlab-sa
namespace: gitlab-managed-apps
kubectl config view --minify=true --flatten -o json | jq '.clusters[0].cluster."certificate-authority-data"' -r | base64 --decode
sudo apt-get install cryptsetup
lsblk
# create a partition manually with fdisk on /dev/sdb
sudo fdisk /dev/sdb
sudo cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb1
sudo cryptsetup luksDump /dev/sdb1
sudo cryptsetup luksOpen /dev/sdb1 sdb1
# format and mount the partition