Skip to content

Instantly share code, notes, and snippets.

View lbbedendo's full-sized avatar

Leonardo Barbieri Bedendo lbbedendo

View GitHub Profile
@lbbedendo
lbbedendo / select_last_sequence_value_pg.sql
Created October 19, 2023 17:58
Select last value of PostgreSQL sequence
SELECT last_value FROM sequence_name;
@lbbedendo
lbbedendo / update_pg_sequence.sql
Created October 19, 2023 17:57
Update PostgreSQL sequence with max(id) + 1
SELECT setval(pg_get_serial_sequence('table_name', 'id'), coalesce(max(id),0) + 1, false) FROM table_name;
@lbbedendo
lbbedendo / disable_psr.sh
Last active October 1, 2023 22:25
Disable Panel Self Refresh on Pop!_OS 22.04
#This command solves a recurrent audio problem on my Dell G3 3590
#For some reason the audio suddenly loses definition in some random situations (during video calls, after screen blank, etc)
sudo kernelstub -a "i915.enable_psr=0"
#Hardware info (neofetch output):
# ///////////// lbarbieri@pop-os
# ///////////////////// ----------------
# ///////*767//////////////// OS: Pop!_OS 22.04 LTS x86_64
# //////7676767676*////////////// Host: G3 3590
# /////76767//7676767////////////// Kernel: 6.4.6-76060406-generic
@lbbedendo
lbbedendo / delete_pod_forcefully.sh
Created April 25, 2023 19:05
Forcefully delete a kubernetes pod
kubectl delete pod <PODNAME> --grace-period=0 --force --namespace <NAMESPACE>
@lbbedendo
lbbedendo / awscli_describe_network_interfaces.sh
Last active November 9, 2023 20:57
awcli describe network interfaces
--list private ip addresses from the specified <subnet-id>
aws ec2 describe-network-interfaces --filters Name=subnet-id,Values=<subnet-id> | jq -r '.NetworkInterfaces[].PrivateIpAddress' | sort
--list dependencies of a security group
aws ec2 describe-network-interfaces --filters Name=group-id,Values=<security-group-id>
@lbbedendo
lbbedendo / search_string_recursively.sh
Created April 28, 2022 02:33
Search string recursively
# Pesquisa uma string recursivamente ignorando alguns diretórios comuns em projetos node, java, etc
grep -Hrn 'text_to_find' --exclude-dir 'node_modules' --exclude-dir 'build' --exclude-dir 'bin' --exclude-dir 'public' .
@lbbedendo
lbbedendo / multipull
Created February 3, 2022 18:10
git command to pull from multiple repositories at once
# Edit your .zshrc/.bashrc/whatever and add this line to create an alias
alias multipull="find . -mindepth 1 -maxdepth 1 -type d -print -exec git -C {} pull \;"
@lbbedendo
lbbedendo / pgadmin4_install_linux_mint.sh
Last active April 17, 2024 15:53
Instalando o pgAdmin 4 no Linux Mint (web e/ou desktop)
# Adaptado da página oficial do pgAdmin: https://www.pgadmin.org/download/pgadmin-4-apt/
# Testado na versão 20.3 (una)
#
# Setup the repository
#
# Install the public key for the repository (if not done previously):
sudo curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add
@lbbedendo
lbbedendo / upstream_release.sh
Last active April 25, 2023 19:06
Como identificar qual versão do Ubuntu a sua instalação do Linux Mint é baseada / How to identify which version of Ubuntu your Linux Mint installation is based on
cat /etc/upstream-release/lsb-release
# Example output:
# DISTRIB_ID=Ubuntu
# DISTRIB_RELEASE=20.04
# DISTRIB_CODENAME=focal
# DISTRIB_DESCRIPTION="Ubuntu Focal Fossa"
@lbbedendo
lbbedendo / kubectl_top_pods.sh
Created January 25, 2022 18:34
kubectl top pods sorting by memory or cpu
kubectl top pods --all-namespaces --containers=true --sort-by=memory
kubectl top pods --all-namespaces --containers=true --sort-by=cpu