Skip to content

Instantly share code, notes, and snippets.

View zulhfreelancer's full-sized avatar

Zulhilmi Zainudin zulhfreelancer

View GitHub Profile
@zulhfreelancer
zulhfreelancer / measure-response-time-curl.md
Last active December 15, 2023 19:29
How to measure response time using `curl`?

How to measure response time using curl?

Command:

curl -kv -w '\n* Response time: %{time_total}s\n' <IP_OR_URL>

Example:

@zulhfreelancer
zulhfreelancer / find-kubernetes-role-or-clusterrole-for-serviceaccount.md
Created June 19, 2023 03:41
How to find Kubernetes Role or ClusterRole linked to a specific ServiceAccount?

How to find Kubernetes Role or ClusterRole linked to a specific ServiceAccount?

kubectl get rolebinding,clusterrolebinding --all-namespaces -o jsonpath='{range .items[?(@.subjects[0].name=="SERVICE_ACCOUNT_NAME")]}[{.roleRef.kind},{.roleRef.name}]{end}'
@zulhfreelancer
zulhfreelancer / show-all-docker-build-logs.md
Created June 1, 2023 08:25
How to show all `docker build` logs?

How to show all docker build logs?

docker build -t YOUR-USER-NAME/YOUR-REPO:<YOUR-IMAGE-TAG> --no-cache --progress=plain .
@zulhfreelancer
zulhfreelancer / dynamic-favicon-fetcher.md
Created March 18, 2023 13:12
How to dynamically fetch website favicon image?

Format

https://www.google.com/s2/favicons?domain=example.com

Example

https://www.google.com/s2/favicons?domain=github.com
@zulhfreelancer
zulhfreelancer / view-yaml-gz-k8s-secret.md
Created January 12, 2023 03:02
How to view the content of *.yaml.gz file stored in Kubernetes secret?

How to view the content of *.yaml.gz file stored in Kubernetes secret?

$ kubectl -n <NAMESPACE> get secret <SECRET> -o json | jq -r '.data."prometheus.yaml.gz"' | base64 -d | gunzip
@zulhfreelancer
zulhfreelancer / how-to-check-free-ram-linux.md
Created November 23, 2022 03:14
How to check free RAM/memory on Linux system?
@zulhfreelancer
zulhfreelancer / delete-heroku-apps.sh
Last active April 13, 2023 06:04
How to bulk delete or leave all Heroku apps using bash script, Heroku CLI and jq?
# List all apps
heroku apps
# Delete all apps created by yourself
for app in $(heroku apps --json | jq -r '.[] | select(.owner.email == "<insert-heroku-email-here>") | .name'); do echo $app | heroku apps:destroy $app; done
# Leave all apps created by others where you were a collaborator
for app in $(heroku apps --json | jq -r '.[] | select(.owner.email != "<insert-heroku-email-here>") | .name'); do heroku apps:leave -a $app; done
# List all apps again
@zulhfreelancer
zulhfreelancer / dummy-exporter-deployment.yaml
Created October 31, 2022 08:11
Dummy / fake Prometheus exporter for Kubernetes testing
apiVersion: v1
kind: Namespace
metadata:
name: dummy-exporter
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: dummy-exporter
@zulhfreelancer
zulhfreelancer / list-yaml-root-keys.md
Last active September 5, 2022 01:39
How to list all root keys in YAML file?

Problem

How to list all root keys in YAML file using yq v4 CLI?

Solution

yq4 is my terminal alias for yq above

Let's print all the root keys if they have enabled sub-key e.g.