commands

collection of commands that were useful in some point

Elementals by Michael Connolly
(CC BY-NC 4.0)

server

Using jupyter on a remote server

  • Setup the public keys authentication
  • Start jupyter on remote server:
    • jupyter notebook --no-browser
  • Connect local port localhost:8889 to server port localhost:8888. One way to create a tunnel using ssh
    • ssh -N -L localhost:8889:localhost:8888 server

Open a proxy through server

ssh -N -D 1234 server

Copying file to/from remote server

scp -r server:~/foo/ ./

scp -r ./ server:~/foo/

local

Compact files

c: create z: zip (compact) v: verbose f: file (name of new file)

Use a local python env

install pipenv:

pip install --user pipenv

creates and activates new virtualenv for the current project(folder)

  • pipenv shell

install a package as editable

  • pipenv install -e git+git://github.com/tdsimao/gym-factored.git#egg=gym_factored

Join all pdfs in a directory

  • pdftk *.pdf cat output expenses-overview.pdf

SCREEN

  • Create named screen screen -S <screen name>
  • Reattach named screen screen -r <screen name>

list

  • du -h --max-depth=1 | sort -n
  • du -hs * | sort -h

profile cython code

indluce the following directive on pyx files cython: profile=True

make gif with monitor output of text environment

git clone --recursive https://github.com/asciinema/asciicast2gif.git
cd asciicast2gif
npm install
lein cljsbuild once main && lein cljsbuild once page

./asciicast2gif monitor_output.json test.gif

install gurobipy

  • download the package and extract files to /opt/gurobi/
  • install gurobipy on the current environment:
      cd /opt/gurobi/`
      python setup.py install
      echo "export LD_LIBRARY_PATH=/opt/gurobi/linux64/lib" > ~/.bashrc
      source ~/.bashrc
    
  • get license:
    • /opt/gurobi902/linux64/bin/grbgetkey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  • set license location:
    • echo "export GRB_LICENSE_FILE=/opt/gurobi902/linux64/gurobi.lic" > ~/.bashrc

git

  • push branch to remote with different name
    • git push heroku dev:master
  • word-based diff
    • git diff --color-words
  • new branch without history
    • git checkout --orphan main

git submodules

  1. after cloning a repo with submodules
     git submodule init
     git submodule update
    
  2. clone a repo and authomatically initialize a repo with submodules
    • git clone --recurse-submodules URL

convert pdf to png

  • single page: pdftoppm input.pdf output -f 1 -singlefile -png -r 300
  • full pdf : pdftoppm input.pdf output -png -r 300

conda

  • To initialize conda add the following to the .bashrc file:
    ## >>> conda initialize >>>
    ## !! Contents within this block are managed by 'conda init' !!
    __conda_setup="$('/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
    if [ $? -eq 0 ]; then
      eval "$__conda_setup"
    else
      if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
          . "/opt/anaconda3/etc/profile.d/conda.sh"
      else
          export PATH="/opt/anaconda3/bin:$PATH"
      fi
    fi
    unset __conda_setup
    ## <<< conda initialize <<<
    
  • restart the session or run the following to implement the new configurations
    source .bashrc
    
  • Disable the automatic activation of the base conda env:
    conda config --set auto_activate_base false
    
  • Create the new environment for Python 3.6:
    conda create -n py36 python=3.6 anaconda
    

Activate the new env:

conda activate py36

Deactivate the env:

conda deactivate

search for a package:

conda search <package>

install a package

conda install <package>

installing tensorflow and dependencies in

Assuming the conda environment active

conda install cudatoolkit=10.1.243
conda install cudnn=7.6.0=cuda10.1_0
pip install tensorflow-gpu==1.15