Skip to content

Instantly share code, notes, and snippets.

View caruccio's full-sized avatar
😐
state = not in mood

Mateus Caruccio caruccio

😐
state = not in mood
View GitHub Profile
@caruccio
caruccio / pizza.py
Last active November 1, 2025 17:37
Calculadora de Pizza
#!/usr/bin/env python3
def pizza(qtd_bolas: int, peso_bola: int, hid: int = 75) -> dict:
peso_total = qtd_bolas * peso_bola
sal_g = peso_total * 0.02
ferm_g = 1
agua_g = (peso_total / (hid + 100)) * 70
farinha_g = peso_total - sal_g - agua_g
items = [('farinha', farinha_g), ('agua', agua_g), ('ferm', ferm_g), ('sal', sal_g)]
return dict(items)
@caruccio
caruccio / lowerCamelCase.sh
Created April 10, 2025 18:27
lowerCamelCase
lowerCamelCase()
{
python -c "s='$1'.replace('-','_').title().replace('_',''); print(s[0].lower()+s[1:])"
}
lowerCamelCase adeus_mundo-cruel
adeusMundoCruel
#!/bin/bash
if [ $# -lt 2 ]; then
echo Usage: $0 NEW-REGISTRY NEW-OWNER [push]
exit 1
fi
new_registry="$1"
new_owner="$2"
push="$3"
@caruccio
caruccio / kubectl-setup.sh
Last active July 30, 2025 17:41
Setup basic kubectl bash env
# curl -sLO https://gist.github.com/caruccio/b9eb86e307ecc293d5b832af8c577605/raw/kubectl-setup.sh && bash -i kubectl-setup.sh
mkdir -p ~/bin ~/opt
## PATH
if ! [[ "$PATH" =~ (^|.*:)(~/bin/?|$HOME/bin/?)(:.*|$) ]]; then
echo 'PATH="~/bin:$PATH"' >> ~/.bashrc
export PATH="~/bin:$PATH"
fi
@caruccio
caruccio / for_dir.sh
Created September 9, 2024 13:09
Execute command in a list of directories
# Install: add this function to your ~/.bashrc or ~/.profile
# Open a new shell and use it:
#
# $ for_dir /tmp /home /var -- ls -la
#
function for_dir()
{
local dirs=()
@caruccio
caruccio / kubectl-use_version
Created September 3, 2024 21:16
Select kubectl binary by version
#!/bin/bash
function download()
{
KUBECTL_VERSIONS=(
$(curl -s "https://api.github.com/repos/kubernetes/kubernetes/releases?per_page=100" \
| jq -r '.[] | .tag_name' \
| grep '^v[0-9]\.[0-9][0-9]\?\.[0-9][0-9]\?$' \
| sort -Vr \
| awk -F . '!a[$1 FS $2]++' \
@caruccio
caruccio / terminal-sequence.py
Created June 1, 2024 11:49
Pythonic terminal sequencies
#!/usr/bin/env python
class TermSequence:
'''Reference: https://stackoverflow.com/a/33206814/1006369
'''
sequence = []
# standard 4-bit color codes
black = 30
red = 31
@caruccio
caruccio / canivete.md
Created May 20, 2024 14:51
Talk - Canivete suiço de gambiarras
@caruccio
caruccio / kubectl-show_tls.md
Last active September 19, 2024 14:09
Show decoded tls cert and key from a secret

$ cat kubectl-show_tls

#!/bin/bash

BIN_AWK=${0}.awk

command kubectl get secret -o json "$@" \
  | jq -r 'select(.type="kubernetes.io/tls") | .data|.[]|values|@base64d' \
  | xargs printf "%b" \
@caruccio
caruccio / kubectl-show_secret
Last active September 19, 2024 14:08
Show decoded contents of a secret
#!/bin/bash
usage()
{
echo "Usage: kubectl show-secret [-n namespace] secret [...secret]"
exit
}
while [ $# -gt 0 ]; do
while getopts n: opt; do