Skip to content

Instantly share code, notes, and snippets.

View rluisr's full-sized avatar
🤒
Out sick

Hasegawa Takuya rluisr

🤒
Out sick
View GitHub Profile
mysql> select * from d1.t1;
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
+----+
5 rows in set (0.00 sec)
@rluisr
rluisr / script.sh
Last active May 21, 2021 17:33
Download binary logs from Amazon RDS.
#!/bin/bash
set -eux
MYSQL_HOST=''
MYSQL_USER=''
MYSQL_PASS=''
EXEC_MYSQL="docker run -e MYSQL_PWD=${MYSQL_PASS} -it --rm mysql:5.6 mysql"
EXEC_MYSQLBINLOG="docker run -e MYSQL_PWD=${MYSQL_PASS} -v ${PWD}:/dump -it --rm mysql:5.6 mysqlbinlog"
@rluisr
rluisr / analyze_table.sh
Created May 7, 2021 08:44
Analyze all tables on specified db
#!/bin/bash
DB_NAME=( "db1" "db2" )
for db_name in "${DB_NAME[@]}"; do
for table in $( mysql --login-path=luis_ro -D ${db_name} -Bse "show tables" ); do
mysql --login-path=luis_rw -D ${db_name} -Bse "analyze table $table";
done
done
@rluisr
rluisr / MBP13 pmset
Created December 3, 2020 13:08
result of default pmset on MBP13
System-wide power settings:
Currently in use:
lidwake 1
autopoweroff 1
standbydelayhigh 86400
autopoweroffdelay 28800
proximitywake 1
standby 1
standbydelaylow 10800
ttyskeepawake 1
@rluisr
rluisr / redis.sh
Created May 22, 2020 09:14
Redis failover test
#!/bin/bash
while :
do
redis-cli -h fqdn -a password ping | grep PONG
if [ $? -eq 0 ]; then
echo "ok"
else
echo "ng"
fi
@rluisr
rluisr / .sql
Last active April 8, 2020 08:59
my primary key is anti pattern? replace `db name`
SELECT DISTINCT
t.table_name,
column_name,
column_type,
table_rows,
(stat_value * @@innodb_page_size) / 1024 / 1024 AS index_size_mb
FROM
information_schema.tables t
LEFT JOIN information_schema.columns c
ON c.table_name = t.table_name
@rluisr
rluisr / .sh
Last active February 1, 2024 08:59
(orchestrator) check errant gtid transactions, fix it and execute can-replicate-from-gtid on all cluster and all combinations.
#!/bin/bash
set -eu
readonly CLUSTERS=( $( orchestrator -c clusters ) )
function can_replicate {
for cluster in "${CLUSTERS[@]}"
do
replicas=( $( orchestrator -c which-replicas -i "${cluster}") )
@rluisr
rluisr / .sh
Created December 26, 2019 07:12
wp2static + S3 + CloudFront
#!/bin/bash
#
# generate static files from wordpress, deploy to S3, clear cache of CloudFront.
set -u
readonly BASE_DIR="/mnt/efs/DocumentRoot"
readonly S3_BUCKET=""
readonly CF_DISTRIBUTION_ID=""
readonly WP_UPLOAD_DIR="${BASE_DIR}/wp-content/uploads"
@rluisr
rluisr / .sh
Created October 28, 2019 09:03
retirer all node on Mackerel
!#/bin/bash
set -eu
ids=( $( mkr hosts | jq -r '.[].id' ) )
for id in "${ids[@]}";
do
mkr retire --force ${id}
done
#!/bin/bash
set -e
cf_ips() {
echo "# https://www.cloudflare.com/ips"
echo 'geo $realip_remote_addr $cf {'
echo -e "\tdefault 0;"
for type in v4 v6; do
echo -e "\t# IP$type"