Skip to content

Instantly share code, notes, and snippets.

View lbbedendo's full-sized avatar

Leonardo Barbieri Bedendo lbbedendo

View GitHub Profile
@lbbedendo
lbbedendo / RomanToInteger.java
Created June 23, 2020 11:37
Roman to Integer
import java.util.Map;
public class RomanToInteger {
private static final Map<Character, Integer> symbols =
Map.of('I', 1, 'V', 5, 'X', 10, 'L', 50, 'C', 100, 'D', 500, 'M', 1000);
public int convert(String romanNumeral) {
int result = 0;
for (int i = 0; i < romanNumeral.length(); i++) {
char currentChar = romanNumeral.charAt(i);
@lbbedendo
lbbedendo / MyServiceConfiguration.java
Last active July 8, 2020 17:47
Example using ProxyHttpClient in Micronaut 2.0.0 with Multi-Tenancy
import io.micronaut.context.annotation.ConfigurationProperties;
import java.net.URI;
@ConfigurationProperties("micronaut.http.services.my-service")
public class MyServiceConfiguration {
public static final String ID = "my-service";
private URI url;
public URI getUrl() {
@lbbedendo
lbbedendo / remove_pods_with_error.sh
Created October 24, 2021 20:57
Removendo pods com erro
kubectl get pods --all-namespaces | grep Error | awk '{print $2, "--namespace", $1}' | xargs kubectl delete pod
@lbbedendo
lbbedendo / list_all_pods_of_node.sh
Created January 24, 2022 12:48
list all pods of node
# list all nodes
kubectl get nodes
# list all pods of specified node
kubectl get pods --all-namespaces -o wide --field-selector spec.nodeName=<node-name>
@lbbedendo
lbbedendo / kubedf.sh
Created January 24, 2022 14:49 — forked from redmcg/kubedf
Bash script to show k8s PVC usage
#!/usr/bin/env bash
function getNodes() {
kubectl get --raw=/api/v1/nodes | jq -r '.items[].metadata.name'
}
function getPVCs() {
jq -s '[flatten | .[].pods[].volume[]? | select(has("pvcRef")) | '\
'{name: .pvcRef.name, capacityBytes, usedBytes, availableBytes, '\
'percentageUsed: (.usedBytes / .capacityBytes * 100)}] | sort_by(.name)'
@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
@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 / pgadmin4_install_linux_mint.sh
Last active May 24, 2024 03:45
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 / 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 / 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' .