Skip to content

Instantly share code, notes, and snippets.

@ggrrll
Last active April 2, 2025 14:36
Show Gist options
  • Select an option

  • Save ggrrll/b83e05eeb16c31204fdaffd42ecc365a to your computer and use it in GitHub Desktop.

Select an option

Save ggrrll/b83e05eeb16c31204fdaffd42ecc365a to your computer and use it in GitHub Desktop.

Revisions

  1. ggrrll revised this gist Apr 2, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    https://www.cheatsheet.wtf/Nano/


    * useful prompt (when workin on git repos):
    * useful prompt (when working in git repos):
    ```
    # Show Git branch in the prompt
    parse_git_branch() {
  2. ggrrll revised this gist Apr 2, 2025. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,16 @@
    https://www.cheatsheet.wtf/Nano/


    * useful prompt (when workin on git repos):
    ```
    # Show Git branch in the prompt
    parse_git_branch() {
    git branch 2>/dev/null | grep '*' | sed 's/* //'
    }
    # Customize the prompt with different colors for user and hostname
    export PS1="\[\033[34m\]\u\[\033[00m\]@\[\033[36m\]\h \[\033[32m\]\w\[\033[33m\] on git:\$(parse_git_branch)\[\033[00m\] $ "
    ```

    * `grep` [with logic or](https://unix.stackexchange.com/a/177521/143800) `grep -e patter1 -e pattern1`
    * [file stats](https://www.baeldung.com/linux/get-file-creation-date): `stat [file]` and `debugfs`
  3. ggrrll revised this gist Nov 13, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -244,6 +244,7 @@ https://stackoverflow.com/questions/4544784/how-can-you-get-the-call-tree-with-p
    # VS code

    * list of python symbols https://code.visualstudio.com/docs/editor/intellisense
    * to activate the right env/kernel, in interactive script: sclick at the symbol , at the top right, in the interactive tab, and select your interpreter

    # Jupyter notebook

  4. ggrrll revised this gist Oct 25, 2024. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -200,6 +200,10 @@ from https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/

    # Python

    ## profilers

    https://stackoverflow.com/questions/4544784/how-can-you-get-the-call-tree-with-python-profilers

    ## parallelization

    * joblib: https://joblib.readthedocs.io/en/latest/
  5. ggrrll revised this gist Oct 8, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -387,7 +387,7 @@ https://docs.docker.com/develop/develop-images/guidelines/
    * `docker push [full_tag]`
    * `docker inspect [image_ID]`
    * ` docker run -it [full_tag]` (to run a container on that image)
    * `docker exec -it <mycontainer> bash` to log into a container shell
    * `docker exec -it <mycontainer> bash` to log into a container shell (add `-u 0` to login as **root**)

    * containers
    * `docker ps -a`
  6. ggrrll revised this gist Apr 17, 2024. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -333,6 +333,12 @@ refs:
    https://amber-md.github.io/pytraj/latest/tutorials/remote_jupyter_notebook
    https://towardsdatascience.com/running-jupyter-notebooks-on-remote-servers-603fbcc256b3

    ## presentation

    https://voila.readthedocs.io/en/stable/using.html is a nice tool to make nb nore suitable for presentations

    tricks:
    * show code cells with `--strip_sources=False`

    ## python packaging

  7. ggrrll revised this gist Mar 27, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -271,6 +271,7 @@ this is problematic...many things tried (none worked):
    ## plotting

    * matplotlib backends https://stackoverflow.com/a/36021869/5533078
    * save **plotly** graphs inside nb, after export https://community.plotly.com/t/exporting-jupyterlab-notebook-as-html-plotly-loses-interactiveness/15310

    ## saving outputs

  8. ggrrll revised this gist Feb 8, 2024. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -233,6 +233,9 @@ from https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/

    * extract numbers from strings (e.g. filenames) https://stackoverflow.com/a/4703409/5533078

    * get variable name :)!
    * in list: https://stackoverflow.com/a/52038959/5533078
    * simple variable: https://stackoverflow.com/a/58451182/5533078

    # VS code

  9. ggrrll revised this gist Jan 9, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -263,6 +263,7 @@ this is problematic...many things tried (none worked):
    [here are a description of commands + GUI](https://towardsdatascience.com/debugging-jupyter-notebooks-will-boost-your-productivity-a33387f4fa62)

    - in `iPython`, better to use `%autoreload` ([see the doc](https://ipython.org/ipython-doc/3/config/extensions/autoreload.html))
    - code profiling https://jakevdp.github.io/PythonDataScienceHandbook/01.07-timing-and-profiling.html

    ## plotting

  10. ggrrll revised this gist Dec 18, 2023. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -217,7 +217,9 @@ from https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/

    ## (sub) plotting

    https://engineeringfordatascience.com/posts/matplotlib_subplots/
    * https://engineeringfordatascience.com/posts/matplotlib_subplots/
    * seaborn:
    * xticks rotation in facegrid https://stackoverflow.com/a/72099702/5533078

    ## debugging

  11. ggrrll revised this gist Dec 14, 2023. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -84,6 +84,10 @@ https://www.cheatsheet.wtf/Nano/

    * colorized `ls` https://askubuntu.com/a/973569/641871

    ## networks

    * [get host's IP](https://www.cyberciti.biz/faq/how-to-find-my-public-ip-address-from-command-line-on-a-linux/) `dig +short myip.opendns.com @resolver1.opendns.com`

    ## useful bashrc / bash_profile

    ```
  12. ggrrll revised this gist Dec 14, 2023. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -376,6 +376,8 @@ https://docs.docker.com/develop/develop-images/guidelines/
    * `docker ps -a`
    * `docker container rm [cont_ID]`
    * `docker restart <container_id>`
    * where to find container logs: `docker inspect --format='{{.LogPath}}' containername
    ` https://stackoverflow.com/a/41147654/5533078


    # Kubernetes
  13. ggrrll revised this gist Dec 7, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -375,6 +375,7 @@ https://docs.docker.com/develop/develop-images/guidelines/
    * containers
    * `docker ps -a`
    * `docker container rm [cont_ID]`
    * `docker restart <container_id>`


    # Kubernetes
  14. ggrrll revised this gist Dec 6, 2023. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -237,7 +237,8 @@ https://engineeringfordatascience.com/posts/matplotlib_subplots/
    ## layout

    * [decrease side space](https://stackoverflow.com/questions/21971449/how-do-i-increase-the-cell-width-of-the-jupyter-ipython-notebook-in-my-browser) -- mind the different css code for notebook 7 https://stackoverflow.com/a/76778615/5533078

    -- see also https://github.com/jupyter/notebook/discussions/7152

    ## `%load_ext autoreload`

    this is problematic...many things tried (none worked):
  15. ggrrll revised this gist Dec 1, 2023. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -353,7 +353,8 @@ https://docs.docker.com/develop/develop-images/guidelines/

    ## tips

    add a label to existing image https://stackoverflow.com/a/54598281/5533078
    * add a label to existing image https://stackoverflow.com/a/54598281/5533078
    * tool to visualize containers & images relations https://github.com/justone/dockviz

    ## docker on github

  16. ggrrll revised this gist Nov 30, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -368,6 +368,7 @@ add a label to existing image https://stackoverflow.com/a/54598281/5533078
    * `docker push [full_tag]`
    * `docker inspect [image_ID]`
    * ` docker run -it [full_tag]` (to run a container on that image)
    * `docker exec -it <mycontainer> bash` to log into a container shell

    * containers
    * `docker ps -a`
  17. ggrrll revised this gist Nov 28, 2023. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -69,7 +69,9 @@ https://www.cheatsheet.wtf/Nano/

    * working on remote with sublime :) > https://github.com/randy3k/RemoteSubl

    * (touchpad behaviour xinput https://www.reddit.com/r/Kubuntu/comments/bsyr6o/how_to_invert_buttons_below_the_touchpad/ )
    * touchpad behaviour (`xinput`)
    * [how_to_invert_buttons_below_the_touchpad/](https://www.reddit.com/r/Kubuntu/comments/bsyr6o/how_to_invert_buttons_below_the_touchpad/)
    * [change scrolling speed](https://askubuntu.com/questions/1413750/how-to-change-2-finger-touchpad-scroll-speed-on-ubuntu-22-04)

    * close __background__ ssh tunnel (`ssh -f`) : https://unix.stackexchange.com/a/164656/143800

  18. ggrrll revised this gist Nov 24, 2023. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -225,6 +225,11 @@ https://engineeringfordatascience.com/posts/matplotlib_subplots/

    * extract numbers from strings (e.g. filenames) https://stackoverflow.com/a/4703409/5533078


    # VS code

    * list of python symbols https://code.visualstudio.com/docs/editor/intellisense

    # Jupyter notebook

    ## layout
  19. ggrrll revised this gist Nov 14, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -229,7 +229,7 @@ https://engineeringfordatascience.com/posts/matplotlib_subplots/

    ## layout

    * [decrease side space](https://stackoverflow.com/questions/21971449/how-do-i-increase-the-cell-width-of-the-jupyter-ipython-notebook-in-my-browser): in `~/.jupyter/custom/custom.css` , put `.container { width:100% !important; }`
    * [decrease side space](https://stackoverflow.com/questions/21971449/how-do-i-increase-the-cell-width-of-the-jupyter-ipython-notebook-in-my-browser) -- mind the different css code for notebook 7 https://stackoverflow.com/a/76778615/5533078

    ## `%load_ext autoreload`

  20. ggrrll revised this gist Nov 13, 2023. 1 changed file with 5 additions and 6 deletions.
    11 changes: 5 additions & 6 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -203,12 +203,11 @@ from https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/

    ## code analysis

    * code map tools:
    * [neo4j](https://towardsdatascience.com/building-a-map-of-your-python-project-using-graph-technology-visualize-your-code-6764e81f3500)
    * UML diagram tools: [see discussion and comment on GH](https://stackoverflow.com/questions/74478335/suggestions-for-code-map-tools-python-project) and [this good review](https://modeling-languages.com/uml-tools/#python); see also this [description of UML diagram conventions](https://paulrumyancev.medium.com/uml-class-diagram-arrows-guide-37e4b1bb11e)
    * [pynsource](https://github.com/abulka/pynsource) -- nice , but needs pro
    * pylint: FOSS, not interactive (webp cannot be generated...to double check)
    * ~epydoc~ : does not work with python3

    * UML diagram tools: [see discussion and comment on GH](https://stackoverflow.com/questions/74478335/suggestions-for-code-map-tools-python-project) and [this good review](https://modeling-languages.com/uml-tools/#python); see also this [description of UML diagram conventions](https://paulrumyancev.medium.com/uml-class-diagram-arrows-guide-37e4b1bb11e)
    * [pynsource](https://github.com/abulka/pynsource) -- nice , but needs pro
    * pylint: FOSS, not interactive (webp cannot be generated...to double check)
    * ~epydoc~ : does not work with python3

    ## (sub) plotting

  21. ggrrll revised this gist Nov 7, 2023. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -104,6 +104,17 @@ if [ -x /usr/bin/dircolors ]; then
    alias egrep='egrep --color=auto -n'
    fi
    # don't put duplicate lines or lines starting with space in the history.
    # See bash(1) for more options
    HISTCONTROL=ignoredups
    # append to the history file, don't overwrite it
    shopt -s histappend
    # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
    HISTSIZE=
    HISTFILESIZE=
    ```

    ## GPU monitornig
  22. ggrrll revised this gist Nov 7, 2023. 1 changed file with 18 additions and 0 deletions.
    18 changes: 18 additions & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -85,6 +85,24 @@ https://www.cheatsheet.wtf/Nano/
    ## useful bashrc / bash_profile

    ```
    # some more ls aliases
    alias ll='ls -larth -F'
    alias la='ls -Al'
    alias l='ls -CF'
    alias nano='nano -L -N -c'
    #alias less='less -N'
    alias diff='diff --suppress-common-lines --color=always -y'
    if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'
    alias grep='grep --color=auto -n'
    alias fgrep='fgrep --color=auto -n'
    alias egrep='egrep --color=auto -n'
    fi
    ```

  23. ggrrll revised this gist Nov 7, 2023. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -81,6 +81,13 @@ https://www.cheatsheet.wtf/Nano/
    * fuzzy search in bash history https://github.com/junegunn/fzf

    * colorized `ls` https://askubuntu.com/a/973569/641871

    ## useful bashrc / bash_profile

    ```
    ```

    ## GPU monitornig

    * `lspci | grep VGA `
  24. ggrrll revised this gist Oct 23, 2023. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -309,6 +309,9 @@ https://docs.docker.com/develop/develop-images/instructions/

    https://docs.docker.com/develop/develop-images/guidelines/

    ## tips

    add a label to existing image https://stackoverflow.com/a/54598281/5533078

    ## docker on github

  25. ggrrll revised this gist Oct 23, 2023. 1 changed file with 12 additions and 2 deletions.
    14 changes: 12 additions & 2 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -303,7 +303,18 @@ https://towardsdatascience.com/running-jupyter-notebooks-on-remote-servers-603fb

    [manage-docker-as-a-non-root-user](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user)

    some useful commands
    ## general good practises

    https://docs.docker.com/develop/develop-images/instructions/

    https://docs.docker.com/develop/develop-images/guidelines/


    ## docker on github

    * [github working-with-the-container-registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry)

    ## some useful commands

    * images
    * `docker image ls`
    @@ -317,7 +328,6 @@ some useful commands
    * `docker ps -a`
    * `docker container rm [cont_ID]`

    * [github working-with-the-container-registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry)

    # Kubernetes

  26. ggrrll revised this gist Oct 19, 2023. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -55,6 +55,8 @@ https://www.cheatsheet.wtf/Nano/
    * `cmp --silent $old $new || echo "files are different"`
    * use a checksum

    * compares files contained in two folders -> https://gist.github.com/ggrrll/7ab0107182c30e9154dd3e7d6e48b62a

    * ssh connection timeout
    * https://www.tecmint.com/increase-ssh-connection-timeout/ & https://man.openbsd.org/ssh_config
    * https://stackoverflow.com/questions/4936807/how-to-set-ssh-timeout
  27. ggrrll revised this gist Oct 17, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -315,7 +315,7 @@ some useful commands
    * `docker ps -a`
    * `docker container rm [cont_ID]`

    * [working-with-the-container-registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry)
    * [github working-with-the-container-registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry)

    # Kubernetes

  28. ggrrll revised this gist Oct 17, 2023. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -314,7 +314,8 @@ some useful commands
    * containers
    * `docker ps -a`
    * `docker container rm [cont_ID]`
    *

    * [working-with-the-container-registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry)

    # Kubernetes

  29. ggrrll revised this gist Oct 17, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -49,6 +49,7 @@ https://www.cheatsheet.wtf/Nano/
    * Press `Ctrl+Z` to pause the currently running process.
    * Type `bg` and press Enter
    * `disown jobID` (list with `jobs -l` or `ps aux`)
    * reown / reattach: https://github.com/nelhage/reptyr

    * compare two files -- [SO question](https://stackoverflow.com/questions/12900538/fastest-way-to-tell-if-two-files-have-the-same-contents-in-unix-linux)
    * `cmp --silent $old $new || echo "files are different"`
  30. ggrrll revised this gist Oct 16, 2023. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion useful_tips.md
    Original file line number Diff line number Diff line change
    @@ -296,7 +296,10 @@ https://towardsdatascience.com/running-jupyter-notebooks-on-remote-servers-603fb

    * mind to use lowercase letters only in yml! -> https://github.com/orgs/community/discussions/69617

    # Docker
    # Docker

    [manage-docker-as-a-non-root-user](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user)

    some useful commands

    * images