Skip to content

Instantly share code, notes, and snippets.

View bdhmiloo's full-sized avatar
:octocat:

Ray bdhmiloo

:octocat:
  • Singapore
  • 05:41 (UTC +08:00)
View GitHub Profile
@bdhmiloo
bdhmiloo / reset-git-history.sh
Last active July 12, 2025 01:52
Reset git history
# Reset Git history to a single commit
# 1. Create an orphan branch (no history)
git checkout --orphan temp-branch
# 2. Add all files to the new branch
git add .
# 3. Commit the current state
git commit -m "Initial commit"
@bdhmiloo
bdhmiloo / query-logs-by-traceid.sh
Last active July 9, 2025 03:48
Utility to query aws logs by trace id
#!/bin/bash
if [ "$#" -ne 4 ]; then
echo "Usage: $0 <start_time> <end_time> <log_group_name> <trace_id>"
echo 'Example: $0 "2025-07-09 00:00:00" "2025-07-09 23:59:59" /aws/lambda/log_group_name 1-686dd42e-de1fff5def777620facd7b76'
exit 1
fi
START_TIME="$1"
END_TIME="$2"
@bdhmiloo
bdhmiloo / exec-jumphost.sh
Created June 23, 2025 07:06
AWS exec into a jumphost ecs container
CLUSTER_NAME="ecs-bazinga-sitizapp"
BASTION_CONTAINER="ecss-bazinga-sitizapp-jumphost"
export AWS_REGION=ap-southeast-1
TASK_ARN=$(aws ecs list-tasks --cluster $CLUSTER_NAME --service-name $BASTION_CONTAINER | jq '.taskArns[0]')
TASK_ARN_ARRAY=(`echo $TASK_ARN | tr '/' ' '`)
TASK_ID_ARRAY=(`echo ${TASK_ARN_ARRAY[2]} | tr '"' ' '`)
TASK_ID="${TASK_ID_ARRAY[0]}"
@bdhmiloo
bdhmiloo / idea.vmoptions
Created April 24, 2025 01:57
Intellij IDEA IDE vmoption settings
-Xmx12g
-Xms8g
-XX:MaxMetaspaceSize=4g
-XX:+UseG1GC
@bdhmiloo
bdhmiloo / itermocil-layout.yml
Last active April 3, 2025 03:50
itermocil config
windows:
- name: start
root: ~/Developer
layout: main-vertical
panes:
- name: main
commands:
- reset && clear
- cd hello
- name: session-2
@bdhmiloo
bdhmiloo / download-repo.sh
Created April 3, 2025 03:37
Script to download multiple repositories under the same user
#!/bin/bash
set -euo pipefail
script_name=$(basename "$0")
usage() {
echo "Usage: ./$script_name [clone_location] [base_repo_url]\n"
echo "Example: ./$script_name /path/to/clone git@github.com:bdhmiloo/"
exit 1
@bdhmiloo
bdhmiloo / Dockerfile
Created April 3, 2025 02:50
Flyway container
FROM nexus-docker.ship.gov.sg/flyway/flyway:10.8.1-alpine
RUN mkdir -p /flyway/sql
COPY /sql-scripts/ /flyway/sql/
RUN mkdir -p /flyway/conf
COPY /flyway/flyway.conf /flyway/conf/
ENTRYPOINT ["flyway"]
@bdhmiloo
bdhmiloo / tgcc.sh
Created April 1, 2025 09:53
Terragrunt/Terraform clear cache
#!/bin/bash
find . -type d -name ".terragrunt-cache" -prune -exec rm -rf {} \;
find . -type d -name ".terraform" -prune -exec rm -rf {} \;
find . -type f -name ".terraform.lock.hcl" -prune -exec rm -rf {} \;
@bdhmiloo
bdhmiloo / push-image-to-ecr.sh
Created April 1, 2025 09:37
AWS ECR - Build docker image locally and push to ECR
#!/bin/bash
set -euo pipefail
script_name=$(basename "$0")
usage() {
echo "Usage: ./$script_name <repo> <tag> [account]\n"
echo "Example: ./$script_name some-ecr-repo 123456:654321"
echo " repo - The ecr repository name"
@bdhmiloo
bdhmiloo / cf-detect-drift.sh
Created April 1, 2025 09:30
AWS Cloudformation - Detect drift via aws cli
#!/bin/bash
STACK_NAME=$1
STACK_DRIFT_DETECTION_ID=$(aws cloudformation detect-stack-drift --stack-name "$STACK_NAME" --query 'StackDriftDetectionId' --output text)
echo "Drift detection initiated with ID: $STACK_DRIFT_DETECTION_ID"
STATUS="DETECTION_IN_PROGRESS"
while [ "$STATUS" == "DETECTION_IN_PROGRESS" ]; do
echo "Waiting for drift detection to complete..."