Skip to content

Instantly share code, notes, and snippets.

@andmax
andmax / home_.jupyter_custom_custom.css
Created July 5, 2019 13:10
Hint to have 100%-html-wide jupyter notebook cells
1- The problem is to have wide jupyter notebook cells
2- jupyter lab is not worth to replace jupyter notebook
3- Create this file:
~/.jupyter/custom/custom.css
4- Add this content:
.container {width:100% !important; }
1- Migrate a git repo by first mirroring original (ORI) repo:
git clone --mirror <url to ORI repo> temp-dir
2- Cd to the mirror repo and check local tags and branches:
git tag
git branch -a
3- Remove the link with the original repo:
git remote rm origin
4- Link the local repo to the new repo:
git remote add origin <url to NEW repo>
5- Push all branches and tags to the new repo:
1- The problem is to run a python script remotely using ssh
2- For a long time (days) and avoiding using $ screen
3- Preventing it to be killed when logging off: $ nohup
4- And redirecting stdout/stderr to a file: "&> file.txt"
5- Using python unbuffering to force writes: "python -u"
$ nohup python -u script_to_run.py &> std_out_err.txt &
1- The problem is to find a previous executed command
$ history | grep <command_to_be_found>
@andmax
andmax / rsync_-marzv
Last active July 28, 2020 10:45
Command rsync is more powerful than scp to copy between servers
1- The problem is to copy all files with 3D in their file name
2- From and to specific directories, going recursively, with:
3- -m == --prune-empty-dirs (skip empty directories)
4- -a == --archive -r (do recursion preserving folder structure)
5- -z == --compress (do compression)
6- -v == --verbose (do verbose)
7- It is very important to set the /path/from and /path/to properly,
8- e.g. source path is /dir1/dir2/dir3/dir4 and the intention is to
9- preserve dir3/ forward in the backup so the destination path is
10- /dirA/dirB/dir3/, note that there is no slash at the end of dir4(/)
@andmax
andmax / .bashrc
Last active July 5, 2021 13:14
Good .bashrc file to have in home directory to configure bash shell
# ---------------------------------------------------------------------------------
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
@andmax
andmax / dot_to_run_sh_file
Created December 17, 2019 12:33
Run a shell script using the current shell instead of creating another one
1- To run an sh script file using current shell,
2- where other sh scripts may have been sourced,
3- Add a dot and space before running it:
$ . <file_to_run.sh>
4- To run it creating a new shell use dot slash:
$ ./<file_to_run.sh>
@andmax
andmax / jupyter_nbextension_installation
Last active April 27, 2020 17:42
How to have ExecuteTime in Jupyter cells
1- Install jupyter and its extensions:
$ conda install -c conda-forge jupyter
$ conda install -c conda-forge jupyter_contrib_nbextensions
2- Should be installed on every conda environment
3- Not sure about the install command below, maybe
4- should only be done for the base environment or
5- not be done at all:
$ jupyter contrib nbextension install --user
@andmax
andmax / crontab_start_scripts
Last active April 27, 2020 12:54
Useful crontab and start scripts on a GPU server
On: /etc/crontab
SHELL=/bin/bash
@reboot deepstation /home/deepstation/start_jupyter.sh
@reboot deepstation /home/deepstation/start_tensorboard.sh
On: /home/deepstation/start_jupyter.sh
#!/bin/bash
source /home/deepstation/anaconda3/etc/profile.d/conda.sh
conda activate base
nohup jupyter notebook --port 9114 --ip * &> /home/deepstation/jupyter_notebook_base.log &
@andmax
andmax / glances_install_setup
Last active September 28, 2020 18:54
Use glances to monitor a server resources (CPU, GPU) using browser
1- Install glances from its script to have latest version
2- (Ubuntu package is an old version), run with sudo -E -H
3- for root access preserving user environment and home dir
$ curl -L https://bit.ly/glances | sudo -E -H /bin/bash
4- Maybe py3nvml should also be installed for GPU monitoring:
$ sudo -E -H pip install py3nvml
5- Create dir: /etc/glances if it does not exist and edit:
6- /etc/glances/glances.conf; to allow some file systems and