This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
sudo apt-get install -y build-essential git libreadline-dev zlib1g-dev libssl-dev libbz2-dev libsqlite3-dev libncurses-dev | |
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.13.1 | |
echo ". \"$HOME/.asdf/asdf.sh\"" >> ~/.bashrc | |
echo ". \"$HOME/.asdf/completions/asdf.bash\"" >> ~/.bashrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#取得前十名 access 最多的 IP 位址 | |
cat access_log|awk '{print $1}'|sort|uniq -c|sort -nr|head -10 | |
#取得前十名 access 最多的網頁 | |
cat access_log|awk '{print $11}'|sort|uniq -c|sort -nr|head -10 | |
#取得前十名下載流量最大的 zip 檔案 | |
cat access.log |awk '($7~/\.zip/){print $10 " " $1 " " $4 " " $7}'|sort -nr|head -10 | |
#取得前十名 Loading 最大的頁面 (大於60秒的 php 頁面) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[core] | |
# The home folder for airflow, default is ~/airflow | |
airflow_home = /Users/p1nox/airflow | |
# The folder where your airflow pipelines live, most likely a | |
# subfolder in a code repository | |
dags_folder = /Users/p1nox/airflow/dags | |
# The folder where airflow should store its log files. This location | |
base_log_folder = /Users/p1nox/airflow/logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file_to_disk = './tmp/large_disk.vdi' | |
Vagrant::Config.run do |config| | |
config.vm.box = 'base' | |
config.vm.customize ['createhd', '--filename', file_to_disk, '--size', 500 * 1024] | |
config.vm.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
check process mysqld with pidfile /var/run/mysqld/mysqld.pid | |
group database | |
group mysql | |
start program = "/etc/init.d/mysql start" | |
stop program = "/etc/init.d/mysql stop" | |
if failed host localhost port 3306 protocol mysql with timeout 15 seconds for 3 times within 4 | |
cycles then restart | |
if failed unixsocket /var/run/mysqld/mysqld.sock protocol mysql for 3 times within 4 cycles then restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Nginx config example | |
``` | |
location /asset { | |
secure_link $arg_md5,$arg_expires; | |
secure_link_md5 "secret$uri$arg_expires"; | |
if ($secure_link = "") { | |
return 403; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 如果碰到 50x 則回 stale content,10 分鐘後會真的看到 50x | |
if (beresp.status == 500 || beresp.status == 501 || beresp.status == 502 || beresp.status == 503 || beresp.status | |
== 504) { | |
set beresp.uncacheable = "True"; | |
set beresp.grace = 10m; | |
return (abandon); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```bash | |
# 啟用 IP forward 預設為 0 = off 避免被當跳板 | |
$ echo '1' > /proc/sys/net/ipv4/ip_forward | |
# 把你要導的 port 導到想導的 IP:PORT 去 | |
$ iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination 192.168.1.1:443 | |
# 使用你的外部 IP 當做 forward 出去所看到的 PORT | |
$ iptables -t nat -A POSTROUTING -j MASQUERADE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GRANT ALL ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION; | |
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE ON db_name.* TO 'username'@'localhost' IDENTIFIED BY 'password'; | |
GRANT ALL PRIVILEGES ON *.* TO 'username'@'127.0.0.%' IDENTIFIED BY 'password' WITH GRANT OPTION; | |
GRANT REPLICATION SLAVE ON *.* TO repl@"192.168.1.%" IDENTIFIED BY 'password'; | |
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE ON db_name.* TO 'username'@'%' IDENTIFIED BY 'password'; | |
GRANT SELECT, LOCK TABLES ON *.* TO ‘backup’@’localhost’ | |
IDENTIFIED BY ‘backup_password’; # mysqldump | |
GRANT SELECT ON *.* TO ‘backup’@’localhost’ | |
IDENTIFIED BY ‘backup_password’; # mysqldump | |
FLUSH PRIVILEGES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
將檔案內不重複的行列出來 | |
awk '!seen[$0]++' <filename> | |
同效 | |
awk '{ if (!seen[$0]) print $0; seen[$0]++ }’ | |
# Print first two fields in opposite order: | |
awk '{ print $2, $1 }' file | |
# Print lines longer than 72 characters: | |
awk 'length > 72' file |