修电脑日常

记录遇见的一些计算机问题的解决方法

linux 安装earlyoom

本站内存太小了,只有2G,容易炸内存,所以装个earlyoom以防死机

sudo apt install earlyoom
sudo systemctl enable earlyoom
sudo systemctl start earlyoom

11代Intel CPU笔记本Window10装机问题

https://zhuanlan.zhihu.com/p/369382342

需要往u盘中塞一个IRST驱动。下载地址F6flpy-x64 (Intel® VMD).zip

win10 关闭 开机自动恢复关机时未关闭的浏览器等

非常坑爹的功能。。

win键->设置->账户->登陆选项->隐私->把 “更新或重启后...” 关闭

win10 关闭 Antimalware Service Executable

打开注册表,路径\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender

右键新建两个DWORD,分别命名为DisableAntiSpyware和DisableAntiVirus,值都设置为1

github push时timeout

家里移动的破网访问github都费劲。所以想要让git也走代理

# 设置http代理
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080

# 设置socks5代理
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'

# 取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy

ghost 文章修改排序方法

ghost默认使用发布时间排序,我改成了按最后修改时间排序

https://stackoverflow.com/questions/29754660/ghost-blog-posts-sort-order

我的ghost版本改orderDefaultOptions没生效,直接改了下面的sql语句。把posts.updated_at和posts.published_at换个位置就行

orderDefaultOptions: function orderDefaultOptions() {    
    return {
        status: 'ASC',
        updated_at: 'DESC',
        published_at: 'DESC',
        id: 'DESC'
    };   
},   

orderDefaultRaw: function (options) {
    let order = '' + 
        'CASE WHEN posts.status = \'scheduled\' THEN 1 ' +
        'WHEN posts.status = \'draft\' THEN 2 ' +
        'ELSE 3 END ASC,' +
        'CASE WHEN posts.status != \'draft\' THEN posts.updated_at END DESC,' +
        'posts.published_at DESC,' +
        'posts.id DESC';

tmux 启动失败 can't create socket

看来像是某次重启时,文件没有关闭造成的。

然后在 这里 找到了答案,使用 strace命令,可以看程序执行时进行的操作和报错的情况:
strace -e trace=file tmux

在我这里,执行的结果如下:
open("/lib64/tls/libpthread.so.0", O_RDONLY) = 3
access("/bin/bash", X_OK) = 0
access("/home/xxx/.tmux.conf", R_OK) = -1 ENOENT (No such file or directory)
mkdir("/tmp//tmux-501", 0700) = 0
lstat("/tmp//tmux-501", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
can't create socket
Process 3171 detached

看起来是「/tmp/tmux-501」这个目录出了问题,删掉这个目录,tmux就可以正常启动了。

vscode namespace自动缩进问题

在项目根目录下,创建.clang-format文件

UseTab: Never
IndentWidth: 4
BreakBeforeBraces: Allman
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
ColumnLimit: 0
AccessModifierOffset: -4
PointerAlignment: Right

windows ubuntu 双系统差8小时

timedatectl set-local-rtc 1 --adjust-system-clock
echo '
function parse_git_branch() {
        git branch 2> /dev/null | sed -e '"'"'/^[^*]/d'"'"' -e '"'"'s/* \(.*\)/ (\1)/'"'"'
}
' >> $HOME/.bashrc
sed -i '/if \[ "$color_prompt" = yes \]; then/{n;s/.*/    PS1='"'"'${debian_chroot:+($debian_chroot)}\\[\\033[0;33m\\][$(date +%H:%M:%S)] \\[\\033[01;32m\\]\\u@\\h\\[\\033[0;31m\\]$(parse_git_branch)\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '"'"'/g}' $HOME/.bashrc

linux 开启swap

# 创建2048(2G)虚拟内存
sudo dd if=/dev/zero of=/swapfile count=2048 bs=1M

# 激活swap
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

# 开机自启动swap
sudo vim /etc/fstab
# 在 fstab 文件最后一行添加下面的内容
/swapfile none swap sw 0 0

# 关闭swap
sudo swapoff /swapfile
sudo rm /swapfile

解决某些网页无法复制的问题

无非就是设置了一些属性让你无法选中,Chrome F12,在console中执行以下代码

还不行的话,就禁用javascript

var eles = document.getElementsByTagName('*');
for (var i = 0; i < eles.length; i++) {
    eles[i].style.userSelect = 'text';
}

windows 10 安装python,环境变量冲突问题

用户变量的Path里有一条%USERPROFILE%\AppData\Local\Microsoft\WindowsApps,这个目录下有个python。

或者搜索应用执行别名(英文:app execution aliases),关掉python和python3对应的开关

docker 修改镜像

Docker修改已有镜像,并打包生成新的镜像tar文件

提取纯音频

webm转MP4 https://convertio.co/zh/webm-mp4/

mp4 转 mp3 https://www.aconvert.com/cn/audio/mp4-to-mp3/

提取音乐or人声 https://vocalremover.org/ch/

© 皖ICP备20011981号