愛と魔法

代理魔法

Git

设置:

  • git config --global http.proxy http://127.0.0.1:1080
  • git config --global https.proxy https://127.0.0.1:1080

取消:

  • git config --global --unset http.proxy
  • git config --global --unset https.proxy

Linux shell

设置:

  • export http_proxy=http://127.0.0.1:1080
  • export https_proxy=https://127.0.0.1:1080
  • export https_proxy="socks5://127.0.0.1:1080"

取消:

  • 命令只对当前终端生效,重启终端即可
  • 或者unset http_proxy

Powershell

  • $Env:http_proxy="http://127.0.0.1:1080";
  • $Env:https_proxy="http://127.0.0.1:1080"

cmd

设置:

  • set http_proxy=http://127.0.0.1:1080
  • set https_proxy=http://127.0.0.1:1080
  • set http_proxy_user=user
  • set http_proxy_pass=pass
  • set https_proxy_user=user
  • set https_proxy_pass=pass

取消:

  • set http_proxy=
  • set https_proxy=

验证

由于 ping 不走代理,可以使用 curl -v https://www.google.com 验证。

换源魔法

Pip

  • 阿里源: https://mirrors.aliyun.com/pypi/simple/
  • 清华源: https://pypi.tuna.tsinghua.edu.cn/simple/
  • 中科大源: https://pypi.mirrors.ustc.edu.cn/simple/

使用 pip3 install -i <src> <package name> 临时指定安装源

若需要全局换源,则修改~/.pip/pip.conf文件如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn

apt

  • 中科大源: https://mirrors.ustc.edu.cn/ubuntu/
  • 阿里源: http://mirrors.aliyun.com/ubuntu/

修改 /etc/apt/sources.list

使用vim替换可参考如下正则:
:%s/http:\/\/archive.ubuntu.com/https:\/\/mirrors.ustc.edu.cn/g

其他魔法

Github

全站镜像

上面是两个整站镜像,可以浏览和下载。
不建议登录,因为不是直接访问原站,存在安全隐患。

Release镜像

  • download.fastgit.org

将网址中的 github.com 替换为 download.fastgit.org 即可

假设下载链接为 https://github.com/A/A/releases/download/1.0/1.0.tar.gz
转换为 https://download.fastgit.org/A/A/releases/download/1.0/1.0.tar.gz 下载即可

下载加速

Raw加速

将网址中的 raw.githubusercontent.com 替换为 raw.sevencdn.com 即可

将网址中的 github.com 替换为 cdn.jsdelivr.net/gh 即可。
ps. jsdelivr不支持exe下载。

SwitchHosts!

一个可以方便的管理 hosts 配置的软件。

左边栏 => 设置 => 自定义命令可以添加每次更改 hosts 后执行的命令。
windows可以添加ipconfig /flushdns命令,令其每次更改 hosts 后自动刷新。