Skip to content

Instantly share code, notes, and snippets.

View chunkhang's full-sized avatar

Marcus Mu chunkhang

  • Singapore
View GitHub Profile
@chunkhang
chunkhang / git-clonex
Created June 30, 2022 07:21
Git clone that helps with creating folder structure
#!/bin/sh
# Create folder structure before cloning repository
#
# Example:
# Running `git clonex [email protected]:sygnum/securesite.git` is equivalent to:
# $ mkdir -p sygnum/securesite
# $ git clone [email protected]:sygnum/securesite.git sygnum/securesite
url="$1"
if [[ -z "$url" ]]; then
@chunkhang
chunkhang / convert_timezone.zsh
Created June 29, 2022 08:51
Convert time from one timezone to another
#!/usr/bin/env zsh
# Usage:
# convert_timezone <source timezone> <target timezone> <date string...>
#
# Examples:
# Asia/Singapore (now) -> Europe/Zurich
# $ convert_timezone Asia/Singapore Europe/Zurich
#
# Asia/Singapore (4 pm) -> Europe/Zurich
@chunkhang
chunkhang / picsum
Last active March 27, 2020 06:10
Download placeholder image from picsum.photos
#!/usr/bin/env bash
function show-help() {
echo "usage: picsum <width> [height]"
}
function download-image() {
curl --location "https://picsum.photos/${1}/${2}" --output "$3" 2>/dev/null
echo "$3"
}
@chunkhang
chunkhang / config
Last active May 17, 2019 08:34
Dynamic SSH config for bastion and private hosts
# Connect to bastion host
# `ssh bastion`
Host bastion
HostName bastion.example.com
User admin
IdentityFile ~/.ssh/bastion.example.com.pem
# Connect to private host through bastion host
# `ssh bastion+ip-1-2-3-4.example.internal`
Host bastion+*