-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
96 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,93 @@ | ||
# tools/science-online.md | ||
# Science Online | ||
|
||
## 国内源 | ||
|
||
### pip | ||
|
||
``` | ||
vi ~/.pip/pip.conf | ||
[global] | ||
index-url = https://pypi.tuna.tsinghua.edu.cn/simple | ||
[install] | ||
trusted-host = https://pypi.tuna.tsinghua.edu.cn | ||
``` | ||
|
||
### github | ||
|
||
``` | ||
git config --global url.https://kkgithub.com/.insteadOf https://github.com/ | ||
``` | ||
|
||
### homebrew | ||
|
||
https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/ | ||
``` | ||
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api" | ||
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles" | ||
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git" | ||
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git" | ||
export HOMEBREW_PIP_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple" | ||
git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install | ||
/bin/bash brew-install/install.sh | ||
rm -rf brew-install | ||
brew update | ||
``` | ||
|
||
## create ssh tunnel | ||
|
||
``` | ||
ssh -qTfnN -D 1080 [email protected] | ||
``` | ||
|
||
* \-q: quiet模式,忽视大部分的警告和诊断信息(比如端口转发时的各种连接错误) | ||
* \-T: 禁用tty分配(pseudo-terminal allocation) | ||
* \-f: 登录成功后即转为后台任务执行 | ||
* \-n: 重定向stdin为/dev/null,用于配合-f后台任务 | ||
* \-N: 不执行远程命令(专门做端口转发) | ||
|
||
### git 设置 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 | ||
``` | ||
|
||
### npm 设置 socks5 代理 | ||
|
||
``` | ||
npm config set proxy socks5://127.0.0.1:1080 | ||
npm config set https-proxy socks5://127.0.0.1:1080 | ||
npm config delete proxy | ||
npm config delete https-proxy | ||
``` | ||
|
||
### ssh 中位 github.com 设置 socks5 代理 | ||
|
||
``` | ||
vi ~/.ssh/config | ||
Host github.com | ||
HostName github.com | ||
User git | ||
ProxyCommand nc -v -x 127.0.0.1:1080 %h %p | ||
``` | ||
|
||
### bash 设置全局代理 | ||
|
||
``` | ||
export http_proxy="socks5://127.0.0.1:1080" | ||
export https_proxy="socks5://127.0.0.1:1080" | ||
# 取消所有 socks 代理 | ||
unset all_proxy && unset ALL_PROXY | ||
``` | ||
|
||
## Shadowsocks | ||
|
||
|
@@ -85,27 +174,4 @@ cat /etc/shadowsocks-libev/config.json | |
sudo iptables -I INPUT -p tcp --dport 8388 -j ACCEPT | ||
sudo iptables -I INPUT -p udp --dport 8388 -j ACCEPT | ||
sudo ufw allow 8388 | ||
``` | ||
|
||
## create ssh tunnel | ||
|
||
``` | ||
ssh -qTfnN -D 1080 [email protected] | ||
``` | ||
|
||
* \-q: quiet模式,忽视大部分的警告和诊断信息(比如端口转发时的各种连接错误) | ||
* \-T: 禁用tty分配(pseudo-terminal allocation) | ||
* \-f: 登录成功后即转为后台任务执行 | ||
* \-n: 重定向stdin为/dev/null,用于配合-f后台任务 | ||
* \-N: 不执行远程命令(专门做端口转发) | ||
|
||
## config proxy for npm | ||
``` | ||
npm config set proxy socks5://127.0.0.1:1081 | ||
npm config set https-proxy socks5://127.0.0.1:1081 | ||
npm config delete proxy | ||
npm config delete https-proxy | ||
``` |