Skip to content

Instantly share code, notes, and snippets.

@tuxmonteiro
tuxmonteiro / gist:f04623f639c4ddb0c862ff7698dee399
Created October 20, 2025 12:19
Show postgresql function source
\df+ in psql < 16 or \sf or \sf+ in psql 16+
Example:
\sf ta_sma
@tuxmonteiro
tuxmonteiro / AppProperties.java
Created September 22, 2025 16:58 — forked from aoudiamoncef/AppProperties.java
Spring Boot Custom Configuration Properties With Java Records + Validations + Metadata
package com.maoudia;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.bind.DefaultValue;
import org.springframework.validation.annotation.Validated;
import java.net.URI;
#!/bin/bash
echo "########### Setting region as env variable ##########"
export AWS_REGION=sa-east-1
echo "########### Setting up localstack profile ###########"
aws configure set aws_access_key_id access_key --profile=localstack
aws configure set aws_secret_access_key secret_key --profile=localstack
aws configure set region $AWS_REGION --profile=localstack
echo "########### Setting default profile ###########"
# HACK 1 - Resolve VPN problem:
# If using VPN, may be is necessary disable WSL interface BEFORE vpn login and re-enabled this interface AFTER vpn connection successfully
netsh interface set interface "vEthernet (WSL)" disable
...
... vpn login and connect
...
netsh interface set interface "vEthernet (WSL)" enable
@tuxmonteiro
tuxmonteiro / gist:edaee55f1116fbbba641ffd07e42f2c0
Last active October 28, 2024 10:16
Mount a VirtualBox drive image (vdi)
# to create nbd volume
sudo apt-get install qemu qemu-utils
sudo rmmod nbd
sudo modprobe nbd max_part=16
sudo qemu-nbd -c /dev/nbd0 drive.vdi
# to mount/unmount partition
sudo mount /dev/nbd0p1 /mnt
sudo umount /mnt
@tuxmonteiro
tuxmonteiro / using-resourcegroupstaggingapi.sh
Created September 16, 2024 18:58
Gestão ágil de tags em AWS Subnets ou outros recursos
aws ec2 describe-subnets --filters 'Name=vpc-id,Values=MEU_VPC_ID' \
--query "Subnets[*].{Name:(Tags[?Key == 'Name'].Value)[0],Id:SubnetId}" | \
grep -A1 'sn-public' | grep '"Id"' | cut -d'"' -f4 | \
xargs -n1 -I '{}' aws resourcegroupstaggingapi tag-resources \
--tags 'kubernetes.io/role/elb=1' \
--resource-arn-list arn:aws:ec2:us-east-1:MEU_AWS_ACCOUNT:subnet/'{}'
@tuxmonteiro
tuxmonteiro / gist:d162326a8e41635afc159fbf70b7f771
Created February 27, 2024 17:41
Using PAT instead SSH KEY
git config --global url."https://git:${{ secrets.PAT_GH_TOKEN }}@github.com/tuxmonteiro".insteadOf "https://github.com/tuxmonteiro"
git config --global url."https://${{ secrets.PAT_GH_TOKEN }}:x-oauth-basic@github.com/tuxmonteiro".insteadOf "ssh://git@github.com/tuxmonteiro"
@tuxmonteiro
tuxmonteiro / show-nodes.sh
Last active August 25, 2022 21:25
Vendo informacoes dos nodes k8s de forma diferente
kubectl get nodes -o jsonpath='{@}' | \
jq -c '.items[]|{
zone:.metadata.labels."topology.kubernetes.io/zone",
instance_type:.metadata.labels."node.kubernetes.io/instance-type",
hostname:.metadata.labels."kubernetes.io/hostname",
role:.metadata.labels."kubernetes.io/role",
on_demand:.metadata.labels."role.vivareal.io/ondemand" ,
ipv4:.metadata.annotations."projectcalico.org/IPv4Address",
iptun:.metadata.annotations."projectcalico.org/IPv4IPIPTunnelAddr",
node_info: .status.nodeInfo, conditions:[.status.conditions[].message],
@tuxmonteiro
tuxmonteiro / kubectl get nodes --by-age
Created July 20, 2022 20:08 — forked from rbtr/kubectl get nodes --by-age
sort kubernetes nodes by age
kubectl get nodes --sort-by=".status.conditions[?(@.reason == 'KubeletReady' )].lastTransitionTime"
@tuxmonteiro
tuxmonteiro / keybase.md
Last active June 30, 2021 20:03
keybase.md

Keybase proof

I hereby claim:

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

To claim this, I am signing this object: