Skip to content

Instantly share code, notes, and snippets.

Avatar

Zulhilmi Zainudin zulhfreelancer

View GitHub Profile
@zulhfreelancer
zulhfreelancer / regex.md
Last active Mar 23, 2021
Regex to find WIP Golang function comments in VS Code
View regex.md
View global-snippets.code-snippets
// Useful tool:
// https://snippet-generator.app
{
"Go Test": {
"prefix": "test",
"body": [
"func Test(t *testing.T) {",
" //$1",
"}",
""
@zulhfreelancer
zulhfreelancer / delete-github-actions-runs.sh
Last active Mar 9, 2021
Delete all GitHub Actions runs
View delete-github-actions-runs.sh
# ===========================================================================
# Requirements
# * gh CLI: https://cli.github.com (make sure you are logged-in to the CLI)
# * jq CLI: https://stedolan.github.io/jq
# ===========================================================================
export TARGET_USER=github_user_or_org
export TARGET_REPO=github_repo_name
while :
@zulhfreelancer
zulhfreelancer / download-latest-release.sh
Created Feb 26, 2021
Download latest GitHub release and place it inside its own folder (using GitHub CLI)
View download-latest-release.sh
#!/bin/bash
# Requirements:
# * GitHub CLI - https://cli.github.com
# ---
# Notes:
# This script will create a new folder based on the release name e.g.
# v0.0.1 and place the release contents inside it. In this script,
# I'm just interested with YAML files - that's why I have the --pattern
# flags. Feel free to remove it if you want to download everything from the release.
View jq-for-yaml.md
@zulhfreelancer
zulhfreelancer / ttl.sh
Created Feb 5, 2021
How to use TTL.sh (ephemeral Docker image registry) // https://ttl.sh
View ttl.sh
UUID=$(uuidgen | awk '{print tolower($0)}') // generate UUID like "2e98d62e-a9e9-4397-a783-86458972fecc"
IMG=ttl.sh/${UUID}:1h // generate full image path like "ttl.sh/2e98d62e-a9e9-4397-a783-86458972fecc:1h"
docker build -t ${IMG} .
docker push ${IMG}
@zulhfreelancer
zulhfreelancer / kubectl-apply-stdin.md
Last active Feb 15, 2021
How to run "kubectl apply -f" with inline YAML as stdin?
View kubectl-apply-stdin.md
$ kubectl apply -f - <<EOF
<-- insert YAML content here -->
EOF

OR

$ cat file.yaml | kubectl apply -f -
@zulhfreelancer
zulhfreelancer / zsh-prompt-color.md
Last active Jan 14, 2021
How to prepend ZSH prompt with text and background color?
View zsh-prompt-color.md

How to prepend ZSH prompt with text and background color?

Steps:

  1. Open your Oh My ZSH theme file i.e. $ nano ~/.oh-my-zsh/themes/maran.zsh-theme

  2. Add the following code in the PROMPT variable:

@zulhfreelancer
zulhfreelancer / ssh-fingerprint.sh
Created Nov 23, 2020
How to generate a SSH key fingerprint that matched with AWS keypair's fingerprint?
View ssh-fingerprint.sh
$ ssh-keygen -f ~/.ssh/id_rsa.pub -e -m PKCS8 | openssl pkey -pubin -outform DER | openssl md5 -c
@zulhfreelancer
zulhfreelancer / .zshrc-docker-machine
Last active Oct 29, 2020
Docker Machine — bash function to start Docker Engine (daemon) in VirtualBox and sets environment variables for Docker Client (running on host)
View .zshrc-docker-machine
# If Docker Engine in Virtualbox is running, set Docker client environment variables
if [ "$(docker-machine status default)" = "Running" ]
then
eval $(docker-machine env)
fi
# Start Docker Engine function
docker-engine-start () { # <-- if that's too long, you can go with just `des`
echo "================================"
echo "Starting Docker Machine..."