This file contains hidden or 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 统计某一天网站的访问量 | |
awk '{print $1}' /var/log/access.log | sort | uniq | wc -l |
This file contains hidden or 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
<?php | |
function convert($size) | |
{ | |
$unit=array('b','kb','mb','gb','tb','pb'); | |
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i]; | |
} | |
convert(memory_get_usage()); |
This file contains hidden or 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
//============================================ docker-compose重新构建容器并启动 ======================================== | |
docker-compose up --no-deps --build -d | |
echo "" > $(docker inspect --format='{{.LogPath}}' <container_name_or_id>) // docker 清理log日志 | |
//============================================ ssh 解决超时问题 ======================================== | |
cd /etc/ssh | |
grep ClientAlive sshd_config | |
cp sshd_config sshd_config.bak |
This file contains hidden or 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
#tree.bat 生成目录文件 | |
tree /f > list.txt |
This file contains hidden or 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
//获取临近的时间节点,单位s | |
//$ranges 系列时间区间, 如 $ranges = [[6, 9], [13, 15]] | |
// $num 当前秒数 | |
// 如 $num = 1 返回 6; $num = 7 返回 7; $num = 10 返回 13; $num = 16 返回 86400 + 6; | |
function countNextSendSecond($ranges, $num){ | |
array_multisort(array_column($ranges, 0), SORT_ASC, $ranges); | |
foreach($ranges as $range){ | |
if($num >= $range[0] && $num <= $range[1]){ | |
return $num; | |
} |
This file contains hidden or 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
# 参考: https://hub.docker.com/r/dreamcat4/samba/ | |
# 注意 最后一个 用户crm 改成 all 时, mac连接有问题。 | |
docker run --name samba -p 139:139 -p 445:445 -v /home/crm:/mount -d dreamcat4/samba -u "crm;crm" -s "crm;/mount;yes;no;yes;crm" |
This file contains hidden or 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
<?php | |
error_reporting(0); | |
if($_GET['open']==1 && strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')!==false){ | |
header("Content-Disposition: attachment; filename=\"load.doc\""); | |
header("Content-Type: application/vnd.ms-word;charset=utf-8"); | |
} | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> |
This file contains hidden or 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
#进程按照内存占用逆序显示 | |
ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | less | |
#文件夹内批量替换字符串 | |
sed -i "s/127.0.0.1/172.16.1.1/g" `grep 127.0.0.1 -rl ./db.ini` | |
#查看连接你服务器 top10 用户端的 IP 地址 | |
netstat -nat | awk '{print $5}' | awk -F ':' '{print $1}' | sort | uniq -c | sort -rn | head -n 10 | |
#服务器查看出口ip |
This file contains hidden or 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
1. 安装最新版本的nvm(node 版本管理器) | |
sudo apt-get install build-essential libssl-dev | |
curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh -o install_nvm.sh | |
bash install_nvm.sh | |
source ~/.profile | |
source ~/.zshrc | |
nvm install 8.9.4 | |
nvm use 8.9.4 |
This file contains hidden or 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
### how to connect wifi (ubuntu 16.04) | |
> 参考 https://askubuntu.com/questions/16584/how-to-connect-and-disconnect-to-a-network-manually-in-terminal | |
1. 生成wifi密码加密的密文 | |
`# wpa_passphrase SSID PASSWORD > CONFIG_FILE` | |
示例 wpa_passphrase Virus LinuxFTW > wpa.conf | |
2. 查看加密的密文 |