Skip to content

Instantly share code, notes, and snippets.

View guessi's full-sized avatar
🎯
Focusing

guessi guessi

🎯
Focusing
View GitHub Profile
@guessi
guessi / delete-inactive_task_definition_revisions.sh
Created March 4, 2023 06:22
Helper script for cleaning up inactive task definition revisions across regions
#!/usr/bin/env bash
# On Feb 27, 2023, Amazon ECS supports deletion of inactive task definition revisions:
#
# Announcement:
# - https://aws.amazon.com/about-aws/whats-new/2023/02/amazon-ecs-deletion-inactive-task-definition-revisions/
#
# Blog Post:
# - https://aws.amazon.com/blogs/containers/announcing-amazon-ecs-task-definition-deletion/
#
@guessi
guessi / find-unused-security-groups.sh
Created January 22, 2022 07:10
[AWS] Find out unused Security Groups
#!/bin/bash
# Usage:
#
# ./find-unused-security-groups.sh [us-east-1]
#
REGION=${1:-us-east-1}
SECURITY_GROUPS=($(aws ec2 describe-security-groups --no-paginate --region ${REGION} --output json | jq -r '.SecurityGroups[].GroupId'))
@guessi
guessi / es-dump.sh
Created September 25, 2018 08:58
Dump ElasticSearch Log from Cluster 1 to Cluster 2
#!/usr/bin/env bash
# simple script for dumping elastic log from one to another
ES_SRC_ENDPOINT="192.168.0.100:9200"
ES_DST_ENDPOINT="192.168.0.200:9200"
ES_INDEX_NAME="logstash-2018.09.25"
INPUT="http://${ES_SRC_ENDPOINT}/${ES_INDEX_NAME}"
OUTPUT="http://${ES_DST_ENDPOINT}/${ES_INDEX_NAME}"
@guessi
guessi / kube-dns-replicas-calc.py
Created September 5, 2018 08:20
kube-dns-replicas-calc.py
#!/usr/bin/env python3
import argparse
from math import ceil
from prettytable import PrettyTable
def resultTable(coresPerReplica, nodesPerReplica, m, M, s=10):
pretty_table = PrettyTable()
pretty_table.field_names = ["Node", "replicas"]
@guessi
guessi / extract-line-add-friend-links-from-urls.py
Created May 16, 2018 13:18
Simple Helper Script for Extracting LINE Add Friends Links from Given URLs
@guessi
guessi / aws-get-billing-info.sh
Created April 22, 2018 14:25
Helper Script for AWS Billing Infomation
#!/bin/bash
#
# original edition:
# - https://gist.github.com/sechiro/8561684
#
now=`date -u "+%Y-%m-%dT%H:%M:%SZ"`
if [ $(uname) = "Darwin" ]; then
yesterday=`date -u -v-3d "+%Y-%m-%dT%H:%M:%SZ"`
@guessi
guessi / setup-docker-ce.ps1
Last active September 27, 2021 09:13
Minimal Script for Setup Docker-CE/Docker-EE on Windows Server 2016
# for Windows Server 2016 (or above)
# reference:
# - https://github.com/docker/labs/blob/master/windows/windows-containers/Setup-Server2016.md
# - https://docs.docker.com/engine/installation/linux/docker-ce/binaries/
# - https://docs.docker.com/docker-for-windows/install/
# setup basic requirement
Install-Module -Name PowerShellGet -MinimumVersion 1.1.3.2 -Force
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.208 -Force
@guessi
guessi / query-pod-name-by-ipaddr.sh
Created April 4, 2018 13:51
Find Out Pod Name by Query Pod IP Address (Kubernetes)
#!/bin/bash
for pod in $(etcdctl ls /registry/pods/default); do
printf "%-16s ==> %s\n" "$(etcdctl get ${pod} | jq -r '.status.podIP')" "$(basename ${pod})"
done
@guessi
guessi / refresh-ecr-token-for-kubernetes.sh
Last active September 18, 2023 07:11
Refresh ECR Token for Kubernetes - Resolve ECR Token Expired Issue
#!/bin/bash
# prerequisite:
# - ec2 instance should attached proper iam role
# - awscli
# - kubectl
# Usage:
#
# define the following variales in your environment (root account)
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
"LongPathsEnabled"=dword:00000001