Skip to content

Instantly share code, notes, and snippets.

Avatar

Zulhilmi Zainudin zulhfreelancer

View GitHub Profile
@zulhfreelancer
zulhfreelancer / delete-all-evicted-pods.sh
Last active Jul 19, 2022
How to delete all evicted pods from all namespaces?
View delete-all-evicted-pods.sh
#!/bin/bash
# This script is for Mac OSX users. If you are on Linux, replace 'gxargs' with 'xargs'.
# To install 'gxargs' command using Homebrew, run 'brew install findutils' first.
# Without parallel (ideal for small number of pods)
kubectl get pods --all-namespaces | grep Evicted | awk '{print $2 " --namespace=" $1}' | gxargs -n 1 -d '\n' bash -c 'kubectl delete pod $0 $1'
# With parallel (ideal for big number of pods)
# To install 'parallel' command using Homebrew, run 'brew install parallel' first.
@zulhfreelancer
zulhfreelancer / current-context-kubeconfig.md
Created Mar 22, 2022
How to view a specific/current context kubeconfig?
View current-context-kubeconfig.md

If you have multiple Kubernetes contexts (list them by kubectl config get-contexts) and you want to view the kubeconfig for current/selected context, you can use one of the following command:

$ kubectl config view --minify --flatten

OR

$ kubectl config view --minify --raw
@zulhfreelancer
zulhfreelancer / install-tailscale-raspberry-pi.sh
Created Mar 4, 2022
How to install Tailscale Mesh VPN on Raspberry Pi
View install-tailscale-raspberry-pi.sh
#!/bin/bash
# Step 1 - Install Tailscale
sudo apt-get install apt-transport-https && \
curl -fsSL https://pkgs.tailscale.com/stable/raspbian/buster.gpg | sudo apt-key add - && \
curl -fsSL https://pkgs.tailscale.com/stable/raspbian/buster.list | sudo tee /etc/apt/sources.list.d/tailscale.list && \
sudo apt-get update && \
sudo apt-get install -y tailscale && \
sudo tailscale up
@zulhfreelancer
zulhfreelancer / rpi-benchmark.sh
Created Feb 25, 2022
Basic Raspberry Pi Benchmarking Script
View rpi-benchmark.sh
#!/bin/bash
vcgencmd measure_temp
vcgencmd get_throttled
sysbench --test=cpu --cpu-max-prime=20000 --num-threads=4 run >/dev/null 2>&1
vcgencmd measure_temp
vcgencmd get_throttled
sysbench --test=cpu --cpu-max-prime=20000 --num-threads=4 run >/dev/null 2>&1
vcgencmd measure_temp
vcgencmd get_throttled
sysbench --test=cpu --cpu-max-prime=20000 --num-threads=4 run >/dev/null 2>&1
@zulhfreelancer
zulhfreelancer / helm-v3-uninstall-all-releases.sh
Created Jan 27, 2022
[Helm v3] How to uninstall all releases from all namespaces?
View helm-v3-uninstall-all-releases.sh
# Require 'jq'
# https://stedolan.github.io/jq/
helm list -A -o json | jq -r '.[] | .name + " " + .namespace' | xargs -n2 sh -c 'helm uninstall $1 -n $2' sh
@zulhfreelancer
zulhfreelancer / open-a-port-in-oracle-cloud-instance.sh
Last active Dec 23, 2021
How to open a port in Oracle Cloud Instance?
View open-a-port-in-oracle-cloud-instance.sh
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# IMPORTANT
# Make sure you already create an ingress rule for the port that you want to open in Oracle Cloud virtual firewall aka
# "Security Lists". This tutorial might be useful for you:
# ---> https://youtu.be/1AIXULHjabQ
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# SSH into the instance
$ ssh <username>@<ip_address>
@zulhfreelancer
zulhfreelancer / git.md
Created Nov 22, 2021
Git: how to count number of uncommited files?
View git.md

Git: how to count number of uncommited files?

$ git status -uall --porcelain | wc -l
@zulhfreelancer
zulhfreelancer / k8s-ephemeral.sh
Created Oct 8, 2021
Kubernetes ephemeral pod (like `docker run --rm`)
View k8s-ephemeral.sh
kubectl run debug --rm -i --tty --restart=Never --image=alpine --namespace=default -- /bin/sh
@zulhfreelancer
zulhfreelancer / local-ruby-gem.md
Last active May 26, 2022
How to use a local Ruby gem in Rails project?
View local-ruby-gem.md

Situation

You are working on a Rails app that uses a gem named abc. This gem is hosted on RubyGems and the source code of the gem is available at https://github.com/your-username/abc.

You created a new branch locally for your gem (new-feature). You wanted to modify the gem and load it directly to your local Rails app. And, you don't want to push the gem changes to GitHub and publish the gem to RubyGems just yet.

You want all the changes that you made in your local gem directory get reflected immediately in your local Rails app without requiring you to run gem build and gem install command in the gem's local directory.

Steps