Skip to content

Instantly share code, notes, and snippets.

View ziwon's full-sized avatar
🗿
?!

Yeongpil Y. ziwon

🗿
?!
View GitHub Profile
@ziwon
ziwon / rds.sh
Created January 1, 2022 22:41 — forked from onyxraven/rds.sh
Amazon RDS Performance Tuning Settings
#XLarge DBInstanceClassMemory = 15892177440 = 14.8GB
#/32 = 496630545 = 473MB
#/64 = 248315272 = 236MB
#/128 = 124157636 = 118MB
#/256 = 62078818 = 59MB
#/512 = 31039409 = 29MB
#/12582880 = 1263 #default same divisor as max_connections = 4041.6MB = 4237924762
#/25165760 = 623 # half of max_connections = 1993.6MB
#/50331520 = 315 # quarter of max_connections = 1008MB = 1056964608
#*(3/4) #default innodb pool size = 11922309120
@ziwon
ziwon / aws_inspector_cron.sh
Created December 17, 2021 03:08 — forked from shokoe/aws_inspector_cron.sh
Executes AWS Inspector run, export full findings csv file from last completed run, compile a concise counters report including severity and package aggregates by hostname. Full and aggregated report are uploaded to S3.
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/snap/bin
log="/var/log/aws_inspector/aws_inspector_export_rep.log"
template_arn='arn:aws:inspector:us-east-1:XXXXXXXXXXXX:target/xxxxxxxxxx/template/xxxxxxxxxx'
wait_sec='5400'
log_out(){
(($verifymon)) &&\
echo -e "`date +'%Y-%m-%d %H:%M:%S'` (pid $$) -- $1" >> $log ||\
echo -e "`date +'%Y-%m-%d %H:%M:%S'` (pid $$) -- $1" | tee -a $log
@ziwon
ziwon / latency.markdown
Created December 1, 2021 04:27 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@ziwon
ziwon / aws_security_group_details.sh
Created November 19, 2021 07:18 — forked from richadams/aws_security_group_details.sh
A quick and dirty script to list out all security group settings on an AWS account. Barely tested, use at own risk, etc. Requires awscli to be installed.
#!/bin/bash
# Requires: awscli (http://aws.amazon.com/cli/)
# Prints out a list of all security groups and their settings, just for quickly auditing it.
# Your AWS credentials
if [ -z ${AWS_ACCESS_KEY_ID} ]; then
export AWS_ACCESS_KEY_ID='***'
export AWS_SECRET_ACCESS_KEY='***'
fi
@ziwon
ziwon / GNU-Make.md
Created November 18, 2021 08:19 — forked from rueycheng/GNU-Make.md
GNU Make cheatsheet
@ziwon
ziwon / slack.sh
Last active September 23, 2021 15:42 — forked from andkirby/slack.sh
Shell/Bash script for sending slack messages.
#!/usr/bin/env bash
####################################################################################
# Slack Bash console script for sending messages.
####################################################################################
# Installation
# $ curl -s https://gist.githubusercontent.com/andkirby/67a774513215d7ba06384186dd441d9e/raw --output /usr/bin/slack
# $ chmod +x /usr/bin/slack
####################################################################################
# USAGE
# Send message to slack channel/user
@ziwon
ziwon / copy_one_line_per_sec.bash
Created July 24, 2021 07:28 — forked from dlamblin/copy_one_line_per_sec.bash
Subscribing to an AWS region's status RSS feeds in slack
sleep 5; while read -r line; do clear; echo $line; echo "$line" | pbcopy; sleep 1; done < "feed_commands_for_seoul_ap-northeast-2.txt"
@ziwon
ziwon / dr-ec2-instances-per-az.sh
Created June 3, 2021 01:54 — forked from andromedarabbit/dr-ec2-instances-per-az.sh
Get a report on How EC2 instances are deployed across multiple AZs
#!/bin/bash
type csvsql || brew instal csvkit
type jq || brew install jq
type aws || brew intall awscli
TABLE_NAME=tmp
TMP_FILE=${TABLE_NAME}.csv
OUTPUT_FILE="output.csv"
truncate -s 0 "${OUTPUT_FILE}"
@ziwon
ziwon / pods_per_running_instance_type.sh
Last active April 3, 2024 08:55
Get the number of pods per running instance type
#!/bin/bash
export AWS_PROFILE=default
aws ec2 describe-instances --region ap-northeast-2 \
| jq '.Reservations[] | .Instances[] | {type: .InstanceType, tag: .Tags[] | select(.Key=="Name").Value}' \
| jq -s '.' \
| jq 'sort_by(.type) | group_by(.type)[] | {
type: .[0].type,
name: map(.tag)} | "\( .type ): \( .name | join(", ") )"' | tr -d \" | awk -F '' '{if (NF > 110) {print substr($0, 0, 110)".."} else print $0}' \
@ziwon
ziwon / instance-types.sh
Created May 13, 2021 10:13 — forked from trestletech/instance-types.sh
Get all EC2 Instance Types in All Availability Zones
#!/bin/bash
region="ap-northeast-2"
all_az=()
az_per_region=$(aws ec2 describe-availability-zones --region $region --query 'AvailabilityZones[*].[ZoneName]' --output text | sort)
while read -r az; do
all_az+=($az)
done <<< "$az_per_region"