126 gists results Add gist
netnr/ asciinema-demo.cast 2023-02-16 06:48
asciinema demo https://github.com/asciinema/asciinema
查看详情
netnr/ netstat-nc.sh 2022-10-26 12:41
netstat nc 网络工具
yum install net-tools # 安装 netstat
yum install nc.x86_64 # 安装 nc

apt install netcat # 安装 nc

# 查看占用端口
netstat -tunlp

# tcp6 包含 ipv4? ref: https://unix.stackexchange.com/questions/496137
cat /proc/sys/net/ipv6/bindv6only
查看详情
netnr/ boot.sh 2022-09-23 11:29
开机启动
# RedHat
vi /etc/rc.d/rc.local # 编辑,添加开机脚本路径如下

source /home/root/boot.sh
/home/root/boot2.sh arg1

# 配置权限
chmod +x /etc/rc.d/rc.local
chmod +x /home/root/*.sh
查看详情
netnr/ MySQL-Encryption.sql 2022-07-05 11:51
MySQL 数据加密、解密
-- 旧版本加密、解密(已弃用)
INSERT INTO users (username, password) VALUES ('john', ENCODE('guessme', 'salt')); -- 写入加密
SELECT username, DECODE(password,'salt') AS password FROM users WHERE username = 'john'; -- 查询解密

-- 新版本加密、解密(安全级别、性能高)
INSERT INTO users (username, password) VALUES ('steven', aes_encrypt('password', 'salt')); -- 写入加密
SELECT username, aes_decrypt(password,'salt') AS password FROM users WHERE username = 'steven';  -- 查询解密

SET block_encryption_mode = 'aes-256-cbc'; -- 修改加密模式
-- 或添加到配置文件 /etc/my.cnf 重启服务
查看详情
netnr/ install-onlyoffice.sh 2022-05-31 15:27
一键安装 ONLYOFFICE
echo "### 安装 wget unzip"
yum install wget unzip -y
echo "### 移除旧的 oo"
docker stop oo -t 0
docker rm oo
docker rmi onlyoffice/documentserver # 删除 oo 镜像
rm -rf /home/onlyoffice/ # 清除目录
echo "### 创建 oo 目录映射"
mkdir -p /home/onlyoffice/logs && cd /home/onlyoffice/ && mkdir data lib db && pwd && ls # 创建目录
docker info
查看详情
netnr/ backup_sqlserver.sh 2022-03-22 16:22
SQLServer 备份脚本 Linux
# 配置参数(开始)===

ymd=$(date +%Y%m%d)
echo "日期:$ymd"
echo
keepday=5
echo "保留最近天数:$keepday"
echo
dirsync="/package/autosync/sync"
echo "同步目录:$dirsync"
查看详情
netnr/ backup_sqlserver.bat 2022-03-22 15:46
SQLServer 备份脚本 Windows
@echo off

:: 配置参数(开始)===

set ymd=%date:~0,4%%date:~5,2%%date:~8,2%
echo 日期:%ymd%
echo.
set keepday=15
echo 保留最近天数:%keepday%
echo.
查看详情
netnr/ git filter-branch.sh 2022-03-04 14:19
GitHub 泄露密钥,彻底删除历史记录
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch -r 要删除的文件" --prune-empty --tag-name-filter cat -- --all
# 遍历所有 commit,删除文件,重写历史 commit,项目顶层执行

git push origin --all --force # 强行远程推送
查看详情
netnr/ PostgreSQL-Manager.sql 2022-02-08 15:57
PostgreSQL 用户授权
-- 创建用户
CREATE USER dbUser WITH PASSWORD 'Abc123....';

-- 数据库授权用户,此时用户还是没有读写权限,需要授权表
GRANT ALL PRIVILEGES ON DATABASE dbName TO dbUser;

-- 当前数据库下 public schema 的表都授权给 dbUser
GRANT ALL PRIVILEGES ON all tables in schema public TO dbUser;

-- 指定表授权
查看详情
netnr/ tcping 2022-01-18 11:30
Linux TCP ping
apt-get install tcptraceroute -y # 依赖

# 一键安装
wget -O /usr/bin/tcping https://raw.githubusercontent.com/deajan/tcpping/master/tcpping && chmod 755 /usr/bin/tcping
wget -O /usr/bin/tcping http://www.vdberg.org/~richard/tcpping && chmod 755 /usr/bin/tcping # 另一个源


# help
https://github.com/deajan/tcpping
查看详情

链接