2020年12月3日
https://www.gnu.org/software/stow/
stow 可以在你设置的目录下自动创建链接到相对应的目录
mkdir dotfiles #创建目录 stow --dir=/root/dotfiles #设置路径 以.bashrc为例
mv ~/.bashrc ~/dotfiles/bash/.bashrc stow bash 建立的对应目录的位置应该在自己名字的文件夹下面,路径位置跟$HOME的相对路径一样
/root/dotfiles/bash/.bashrc /root/.bashrc tree -a . ├── bash └── .bashrc ……
阅读全文
2020年11月23日
d = new Date('2000-01-01')
output: Fri Dec 31 1999 19:00:00 GMT-0500 (Eastern Standard Time)
d.getYear()
99
d.getMonth()
11
d.getDate()
31
因为时区的问题,显示的时间会跟要存储的时间差一天
加上具体时间” 00:00:00.000”,直接生成的是当地时间。
d.getYear()
100
d.getMonth()
0
d.getDate()
1
d.getFullYear()
2000
……
阅读全文
2020年10月24日
使用telegram的机器人下载文件到谷歌网盘 项目地址 https://github.com/lzzy12/python-aria-mirror-bot
https://github.com/magneto261290/magneto-python-aria
编辑环境变量文件 生成telegraph的token
python3 generate_telegraph_token.py d73ae03dd0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXebaf2e161 填写到TELEGRAPH_TOKEN
API_KEY 输入api_id API_HASH 输入 api_hash bot token输入BotFather获取到的bot的token
获得USER_SESSION_STRING AQCUOk4LsAukvKVZ9k1JK5H2Oo4EtWEJF4sQQ9RkG2fCkLWsZdk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXpy_gPZI42i70rerTWeWLD70a_cd_eHswSU1_IbFjTMexTiA2BgE
到 https://my.telegram.org/ 申请api TELEGRAM_API 填写App api_id TELEGRAM_HASH 填写App api_hash OWNER_ID 到 https://t.me/userinfobot 获取自己的Id
开启谷歌网盘授权 开启drive api https://developers.google.com/drive/api/v3/quickstart/python
安装依赖
pip3 install google-api-python-client google-auth-httplib2 google-auth-oauthlib
下载credentials.json并上传到服务器
生成token
python3 generate_drive_token.py
[email protected]:~/test/m2g/mirror-bot# python3 generate_drive_token.py
Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Enter the authorization code: 4/5AHj9dOAl1h2Kih7zWkCCdY8VtZDrP4TxhYgQ0D4guA4CMnWXJELCD0
docker build . -t mirror-bot docker run -idt mirror-bot 在当前目录新建config.……
阅读全文
2020年10月11日
安装python3.9 到网址找下载链接https://www.python.org/downloads/release/python-390/
安装依赖
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev 解压
tar -xf Python-3.X.X.tar.xz 设置并安装
which openssl //用命令查看openssl位置,设置的时候要用,不然安装好以后缺少openssl不能通过https下载包 ./configure --enable-optimizations --with-openssl=/usr/local/opt/openssl nproc //查看进程数 make -j 4 //此处的数字是进程数 sudo make altinstall (sudo make install) //make install 会直接覆盖系统的python 安装lxml遇到问题
cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitcfhhalla.c -o tmp/xmlXPathInitcfhhalla.o cc tmp/xmlXPathInitcfhhalla.o -lxml2 -o a.out error: command '/usr/bin/gcc' failed with exit code 4 有可能是内存不够,我的机器512MB不够,增加虚拟内存到2G以后安装成功……
阅读全文
2020年7月3日
要访问机器上除了80以外的端口需要域名加上端口链接,这样很不方便,所以就想用nginx把需要的服务代理到80端口。
nginx的配置文件在/etc/nginx/下,新增的网站服务的配置可以直接写下conf.d或者sites-enabled下面。具体可以查看nginx的nginx.conf配置文件中关于Virtual Host Configs的设置
一个比较好的安排配置文件的方法是:在sites-available中保存所有的配置,然后复制需要的配置到sited-enabled启用配置。
假设新建一个newserver配置文件
server { listen 80; server_name {domainname}.com; location / { proxy_pass http://127.0.0.1:8081;#add the port your service are listening proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } 软链接到sites-enabled
cd /etc/nginx cp sites-available/newserver sites-enabled/ ……
阅读全文
2020年7月3日
在尝试了几个windows的终端后,还是觉得windows terminal最好用。
windows terminal 链接 https://github.com/microsoft/terminal
defaultProfile填写配置对应的guid就可以设置默认配置。所有的配置在profiles中。
安装好git之后,windows可以使用bash了。
{ "acrylicOpacity" : 0.9, "closeOnExit" : true, "colorScheme" : "Solarized Light", "commandline" : "C:\\Program Files\\Git\\bin\\bash.exe", "cursorColor" : "#1100fc", "cursorShape" : "bar", "fontFace" : "Consolas", "fontSize" : 12, "guid" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "historySize" : 9001, "icon" : "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico", "name" : "bash", "padding" : "0, 0, 0, 0", "snapOnInput" : true, "startingDirectory" : "%USERPROFILE%", "useAcrylic" : true } ……
阅读全文
2020年6月5日
expect可以帮助我们 自动化完成一些交互操作。
使用expect来执行ssh命令
编写脚本 #!/usr/bin/expect #sshlogin.exp set timeout 30 set host "192.168.1.8" set username "your_username" set password "yout_password" spawn ssh
[email protected]$host #expect "*password:*" {send "$password\r"} expect { "*password:" {send "$password\r"} } interact 给脚本权限
chmod 755 运行脚本
./sshlogin.exp 使用一行命令直接运行
expect -c 'spawn ssh {{username}}@{{host}}; expect "*password:*"; send "{{password}}\r"; interact' references:
https://en.wikipedia.org/wiki/Expect
https://stackoverflow.com/questions/3149367/how-to-get-expect-c-to-work-in-single-line-rather-than-script……
阅读全文
2020年6月2日
到戴尔官网下载驱动 https://www.dell.com/support/home/en-us/drivers/driversdetails?driverid=6wgwy
下载autohotkey https://www.autohotkey.com/
新建脚本
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ; #Warn ; Enable warnings to assist with detecting common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ^F11:: Run, "C:\Program Files (x86)\Dell\Dell Display Manager\ddm.exe" /1:SetActiveInput DP1 Return ^F12:: Run, "C:\Program Files (x86)\Dell\Dell Display Manager\ddm.exe" /1:SetActiveInput HDMI Return 当你有两个显示器的时候,把后面参数1替换成2就可以了……
阅读全文
2020年6月1日
安装
sudo apt-get install tmux 启动tmux
tmux 命令
tmux ls #查看到当前在运行的所有tmux sessions会话 tmux attach #进入上次退出的会话 tmux attach -t {{number}} #进入会话 tmux new -s <session-name> #新建会话 tmux kill-session -t {{number}} #结束会话 常用快捷键
先输入ctrl-b 然后用下面按键执行操作
d 离开会话,会话会运行在后台……
阅读全文
2020年3月13日
修改公网机器的配置
修改sshd_config
vim /etc/ssh/sshd_config
#GatewayPorts no => GatewayPorts yes
#重启ssh服务
sudo /etc/init.d/ssh stop
[email protected]:~# sudo /etc/init.d/ssh start
内网机器端口转发(假设内网的机器端口80要转发到公网机器的9091端口上)
ssh -NR 9091:0.0.0.0:80
[email protected]_ip
……
阅读全文