Skip to content

Instantly share code, notes, and snippets.

View quangnhut123's full-sized avatar

Tran Quang Nhut (Jonny) quangnhut123

View GitHub Profile
#!/bin/bash
# Set up your environment variables
TFC_ORG_SOURCE=""
TFC_ORG_DEST=""
TFC_TOKEN_SOURCE=""
TFC_TOKEN_DEST=""
# Define the list of workspace names to exclude
EXCLUDE_WORKSPACES=("workspace_1" "workspace_2")
#!/bin/bash
TOKEN="TFC_TOKEN"
ORG_NAME="ORG_NAME"
PAGE_SIZE=20
# Function to fetch workspaces for a specific page number
function fetch_workspaces_page {
local page="$1"
curl -s -H "Authorization: Bearer $TOKEN" \
import os
import yaml
# Define the folder path containing the YAML files
folder_path = (
"YOUR_BASE_YAML_FOLDER_PATH"
)
# Initialize variables to store the largest offset and access port
largest_offset = -1
@quangnhut123
quangnhut123 / charles-keygen.py
Last active September 8, 2023 15:57
Charles KeyGen
import random
import struct
class SimpleRC5:
P32 = 0xB7E15163
Q32 = 0x9E3779B9
R = 12
def __init__(self, key=None):
@quangnhut123
quangnhut123 / disable_rds_auto_minor_version_upgrade.sh
Last active May 29, 2023 04:49
Disable RDS Auto Minor Version Upgrade
#!/bin/bash
export AWS_REGION=ap-northeast-1
check_profile() {
local profile=$1
local specific_text=$2
# Check if the profile contains the specific text
if [[ $profile == *"$specific_text"* ]]; then
return 0 # The string is found
else
@quangnhut123
quangnhut123 / check_ecr_cost.sh
Last active May 24, 2023 03:30
Check ECR Cost and Usage
#!/bin/bash
export AWS_REGION=ap-northeast-1
process_profile() {
local profile=$1
echo -e "\n\n========== Processing profile: $profile =========="
export AWS_PROFILE=$profile
# Get the ECR cost and usage for the current month
local start_date=$(date -v1d +%Y-%m-%d)
kubecontext=$(kubectl config view -o jsonpath='{.contexts[*].name}')
oldIFS=$IFS
IFS=$' '
choices=( $kubecontext )
IFS=$oldIFS
PS3="Please select your kube context: "
select answer in "${choices[@]}"; do
for item in "${choices[@]}"; do
if [[ $item == $answer ]]; then
break 2
@quangnhut123
quangnhut123 / base_color.user.js
Last active September 30, 2024 02:12
Base Checkin Advanced Color
// ==UserScript==
// @name Base Checkin Color
// @namespace base
// @version 0.9
// @description Color base on checkin time
// @author Anonymous
// @match https://checkin.base.vn/me*
// @icon https://static-gcdn.basecdn.net/checkin/image/fav.png
// @grant none
// ==/UserScript==
#!/bin/bash
while getopts c:s: flag
do
case "${flag}" in
c) cluster_name=${OPTARG};;
s) service_name=${OPTARG};;
esac
done
#!/bin/bash
# Docker CE Install
sudo yum update -y
sudo yum install -y jq
sudo amazon-linux-extras install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
# Make docker auto-start