Skip to content

Instantly share code, notes, and snippets.

View quangnhut123's full-sized avatar

Tran Quang Nhut (Jonny) quangnhut123

View GitHub Profile
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 October 30, 2023 05:05
Base Checkin Advanced Color
// ==UserScript==
// @name Base Checkin Advanced Color
// @namespace base
// @version 0.6
// @description Color base on checkin time
// @author Jonny
// @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
@quangnhut123
quangnhut123 / get_kubeconfig_custom_cluster_rancher2.sh
Created August 23, 2018 11:00 — forked from superseb/get_kubeconfig_custom_cluster_rancher2.sh
Get kubeconfig for custom cluster in Rancher 2.0
#!/bin/bash
# Usage: ./get_kubeconfig_custom_cluster_rancher2.sh cluster_name
# Needs to be run on the server running `rancher/rancher` container
# Check if jq exists
command -v jq >/dev/null 2>&1 || { echo "jq is not installed. Exiting." >&2; exit 1; }
# Check if clustername is given
if [ -z "$1" ]; then
echo "Usage: $0 [clustername]"
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: tiller