Skip to content

Instantly share code, notes, and snippets.

# nginx 统计某一天网站的访问量
awk '{print $1}' /var/log/access.log | sort | uniq | wc -l
@digjack
digjack / memory_usage.php
Created June 7, 2018 05:39 — forked from mehdichaouch/memory_usage.php
PHP Snippet to get human readable memory usage
<?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());
@digjack
digjack / linux-command
Last active February 17, 2019 10:31
常用的 linux 命令
//============================================ 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
@digjack
digjack / windows bat file
Created June 23, 2018 18:24
常用windows脚本
#tree.bat 生成目录文件
tree /f > list.txt
@digjack
digjack / PHP 计算临近的时间节点
Created October 24, 2018 06:52
PHP 计算临近的时间节点
//获取临近的时间节点,单位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;
}
# 参考: 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"
@digjack
digjack / gist:5452a345d03923a58916baf9d16c6193
Created February 16, 2019 15:58
微信下载apk,跳转手机浏览器下载
<?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>
@digjack
digjack / linux 常用命令合集
Last active October 22, 2019 06:12
linux 常用命令合集
#进程按照内存占用逆序显示
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
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
@digjack
digjack / gist:00a080d5ec0698ed44e0f37f40561895
Last active July 8, 2020 03:06
ubuntu16.04 搭建笔记
### 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. 查看加密的密文