Skip to content

Instantly share code, notes, and snippets.

View lbbedendo's full-sized avatar

Leonardo Barbieri Bedendo lbbedendo

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / LongestCommonSubsequence.java
Last active May 13, 2020 00:28
Longest Common Subsequence in java
import java.time.Duration;
import java.time.Instant;
public class LongestCommonSubsequence {
public int lcsRecursive(char[] a, char[] b, int i, int j) {
if (a.length == i || b.length == j)
return 0;
else if (a[i] == b[j])
return 1 + lcsRecursive(a, b, i + 1, j + 1);
else
@lbbedendo
lbbedendo / raspberrypi_hdmi_signal.txt
Last active April 25, 2020 14:00
raspberry pi hdmi signal
Reference: https://www.raspberrypi.org/forums/viewtopic.php?t=34061
The Pi outputs a relatively weak HDMI signal. Some devices may not immediately notice the Pi's HDMI or may not do the negotiation.
Setting the hdmi_force_hotplug=1 makes sure the Pi believes the monitor/TV is really there.
You might also need to set config_hdmi_boost=4 or even higher (up to 9) if your display needs a stronger signal.
If the display is a computer monitor, use hdmi_group=1 and if it is an older TV, try hdmi_group=2.
Do not set hdmi_safe=1 as that overrides many of the previous options.
Using a shorter or better quality HDMI cable might help.
Make sure your Pi's power supply delivers 1A and not 500mA.
If you see a problem with the red colour - either absent, or interference - then try a boost. However it might simply be that the display requires a stronger signal than the Pi can give.
@lbbedendo
lbbedendo / audio_fix_dummy_output.sh
Last active January 7, 2025 18:54
Audio fix for ubuntu 19.10 on Dell G3 3590 (Dummy Output)
# Reference: https://www.linuxuprising.com/2018/06/fix-no-sound-dummy-output-issue-in.html
# Solution 2 fixed my problem (below)
echo "options snd-hda-intel dmic_detect=0" | sudo tee -a /etc/modprobe.d/alsa-base.conf
echo "blacklist snd_soc_skl" | sudo tee -a /etc/modprobe.d/blacklist.conf
# Reboot your system
@lbbedendo
lbbedendo / kubectl.txt
Last active March 3, 2020 18:06
Kubectl commands
kubectl get namespaces
kubectl get pods -n <namespace>
kubectl logs pod/<pod_name> -n <namespace>
kubectl describe pod/<pod_name> -n <namespace>
@lbbedendo
lbbedendo / staircase.kt
Created December 18, 2019 12:55
staircase
import java.util.stream.IntStream
fun stair(n: Int) {
IntStream.range(1, n).forEach {
println(" ".repeat(n - it) + "#".repeat(it))
}
}
fun main() {
print("Enter the stair size: ")