小技巧
· 2 min read
一些常用的小技巧
IP 地址位置查询
curl http://www.geoplugin.net/json.gp?ip=xx.xx.xx.xx
生成随机数
openssl rand -base64 32
ssh 保持与服务端连接
ServerAliveInterval
: 表示每隔多少秒发送一次心跳包(设置为 60 秒)。ServerAliveCountMax
: 指定在服务器无响应的情况下尝试发送多少次心跳包(3 次后断开)。
vim ~/.ssh/config
Host *
ServerAliveInterval 60
ServerAliveCountMax 3
mongodb 创建用户
use dbname # 进入数据库
# 创建用户
db.createUser({
user: 'aa',
pwd: 'aaaaaa',
roles: ['readWrite', 'dbAdmin', 'userAdmin']
})
mongodb 插入管理员
123456 => $2b$10$z4WSs5Ox55mPV8BSZaC8p.rqsur9sKe2/kmWhKKuAesLezqOZDz9S
db.users.insertOne({
username: 'aa',
nickname: 'aa',
password: '$2b$10$z4WSs5Ox55mPV8BS',
createdAt: new Date(),
updatedAt: new Date()
})
配置 docker 源
配置腾讯内部源
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://mirror.ccs.tencentyun.com"]
}
重启
sudo systemctl restart docker
查看源
sudo docker info
游戏最佳适配
背景可以放大适配 scale: 1.3 1.3
- 横屏
- 分辨率:
1280
x720
- 固定高度 - 适配宽度
- 分辨率:
- 竖屏
- 分辨率:
720
x1280
- 固定宽度 - 适配高度
- 分辨率:
mongodb 创建索引
db.users.getIndexes() # 查看所有索引,保存一下即可生成最新索引
db.users.dropIndexes() # 删除所有索引,除了 _id 索引
db.users.createIndex({name: 1}) # 创建索引
# 通过配置 schema.index() 或是 在属性上加 Index 来添加索引
字体提取
# 安装 fonttools
brew install fonttools
# 提取字体
pyftsubset SourceHanSansSC-Regular.ttf \
--output-file=dist/font.ttf \
--text='开始游戏' \
--layout-features='*' \
--glyph-names --symbol-cmap \
--legacy-cmap --notdef-glyph --notdef-outline \
--no-hinting