Skip to content

Instantly share code, notes, and snippets.

Avatar
🤒
Out sick

Hasegawa Takuya rluisr

🤒
Out sick
View GitHub Profile
View blog_1.sql
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
Download binary logs from Amazon RDS.
View script.sh
#!/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
Analyze all tables on specified db
View analyze_table.sh
#!/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 Dec 3, 2020
result of default pmset on MBP13
View MBP13 pmset
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
Redis failover test
View redis.sh
#!/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 Apr 8, 2020
my primary key is anti pattern? replace `db name`
View .sql
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 Feb 17, 2020
(orchestrator) check errant gtid transactions, fix it and execute can-replicate-from-gtid on all cluster and all combinations.
View .sh
#!/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 Dec 26, 2019
wp2static + S3 + CloudFront
View .sh
#!/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 Oct 28, 2019
retirer all node on Mackerel
View .sh
!#/bin/bash
set -eu
ids=( $( mkr hosts | jq -r '.[].id' ) )
for id in "${ids[@]}";
do
mkr retire --force ${id}
done
View update_cf.sh
#!/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"