# Enviroment ## Python ### Pyenv #### install ```!= sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev git clone https://github.com/pyenv/pyenv.git ~/.pyenv git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv ``` add to bashrc ``` export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" ``` ### Jupyter on server ``` (without root previliege) export XDG_RUNTIME_DIR="" jupyter notebook --no-browser --port=[port] ``` on client ``` ssh -NL localhost:[port_client]:localhost:[port_server] [server] ``` ### Run pip with specific python ``` python -m pip install [package] ``` ## Git ### Vimdiff use vimdiff for git diff ``` git config --global diff.tool vimdiff git config --global difftool.prompt false git config --global alias.d difftool ``` ### Switch remote URLs ``` git remote set-url origin [url] ``` ### Create repo from existing dir ``` git init git remote add origin [url] git fetch origin git checkout -b master --track origin/master ``` ## Linux Shell ### file size disk size, file size ``` df -h du -sh [file path] ``` ### watch update per [secs] ``` watch -c -n [secs] ``` ### rsync remote ``` rsync -avzh [source] [destination(directory)] (--delete) ``` ### use specific gpu ``` CUDA_VISIBLE_DEVICES=[gpu id] python ... ``` ### change ssh welcome message modify files in ```/etc/update-motd.d``` and make them executable ## Tmux ### Control * pane to window ```:break-pane -t :[window num]``` ([window num] join to current one) * window to pane ```:join-pane -s :[window num]``` * horizontal to vertical ```prefix + esc : 1``` * swap two panes ```prefix + {``` ### pbcopy (mac) ``` $ brew install reattach-to-user-namespace # ~/.tmux.conf set -g default-shell $SHELL set -g default-command "reattach-to-user-namespace -l ${SHELL}" # ~/.vimrc set clipboard=unnamed ``` ## MISC problems ### Upload to Google Drive from Command Line * [gdrive](https://github.com/prasmussen/gdrive#downloads) 1. download binary file 2. run gdrive get response code 3. ```gdrive upload [file]``` ### X11 on mac * install XQuartz * ```$ ln -s /opt/X11/include/X11 /usr/local/include/X11``` * ```$ xcode-select --install``` ### Tricky Things on Windows #### Python (Cython) * specify VS version ([ref](https://github.com/cython/cython/wiki/CythonExtensionsOnWindows)) * use according cmd to build ``` SET DISTUTILS_USE_SDK=1 SET MSSdk=1 (if setup.py) ```