Skip to content

Instantly share code, notes, and snippets.

View guessi's full-sized avatar
🎯
Focusing

guessi guessi

🎯
Focusing
View GitHub Profile
@guessi
guessi / retrieve-facebook-friends-list.js
Created February 22, 2025 08:36
Retrieve Facebook friends list with your browser
// How to use this script?
//
// 1. Go to your profile page
// 2. Go to "Friend" tab
// 3. Keep scrolling down, until all friends data loaded
// 4. Open browser's "Console" (short cut on macOS: Cmd + F12)
// 5. Execute the script below
//
// Last Modified: Feb 22, 2025
//
@guessi
guessi / purge-github-image-cache.sh
Created January 25, 2025 04:11
Purge image cached by Github
#!/usr/bin/env bash
# https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-anonymized-urls
REPO_URL="https://github.com/guessi/cloudtrail-cli"
curl -fsSL ${REPO_URL} | \
sed -n '/<script .*>/,/<\/script>/p' | \
grep -oE 'https?://camo.githubusercontent.com/[a-f0-9]+/[a-f0-9]+' | \
xargs -n 1 curl -X PURGE
@guessi
guessi / jwt-decode.sh
Created January 24, 2025 07:39
One-liner JWT token decode with PyJWT
# https://pyjwt.readthedocs.io/en/stable/
python3 -m pip install PyJwt
# https://pyjwt.readthedocs.io/en/stable/usage.html#reading-the-claimset-without-validation
echo token_file_name | python3 -c 'import sys,jwt; f = open(sys.stdin.read().strip()); decoded_jwt = jwt.decode(f.readline(), options={"verify_signature": False}); print(decoded_jwt); f.close();'
@guessi
guessi / ffmpeg-resize.sh
Created November 5, 2024 10:10
resize video with ffmpeg
#!/usr/bin/env bash
INPUT="${1}"
OUTPUT="${2}"
SIZE="1920:1080" # horizontal
# SIZE="1080:1920" # vertical
BITRATE_V="4800k"
# https://trac.ffmpeg.org/wiki/Encode/H.265
@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"`