diff --git a/docs/python/django.md b/docs/python/django.md index ace25dd..93e4663 100644 --- a/docs/python/django.md +++ b/docs/python/django.md @@ -12,6 +12,12 @@ datetime.datetime(2005, 8, 20, 13, 35, 12) >>> s.get_decoded() {'user_id': 42} ``` +``` +>>> from django.contrib.sessions.backends.db import SessionStore +>>> s = SessionStore() +>>> s_data = ".eJxVjEEKwjAQAP-yZymbtomJJ_UjYTddqWhbyTaoiH-3RRC8DjPzgiyDDCw5DgK7ORfZQKQy97HoAkdaMQTyLbNhzxjarjaek_O1NQFdwpN1-7WorlOiK_z1TOkiYxfrZaJCfeGKSaWilKYyzlodFvX4ldZSRfU8jVEet3N-ws5h6xE3cCPV-5S7n_ADPWkfL7K4wLY2fApbRkOI6H0jDTvDNtjGNMbB-wMgXU_Z:1rGcFf:4Y53efIteKjKKAkWbOHhT3D6n3Yk0Z_vca2yDP8N-Dc" +>>> decoded_data = s.decode(s_data) +``` ## Database diff --git a/docs/tools/science-online.md b/docs/tools/science-online.md index e90a356..2f7815e 100644 --- a/docs/tools/science-online.md +++ b/docs/tools/science-online.md @@ -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 root@example.com +``` + +* \-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 root@demo.seafile.com - -``` - -* \-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 ```