Skip to content

Instantly share code, notes, and snippets.

@andmax
andmax / update_links.sh
Created December 5, 2018 12:33
Update links in current directory by first deleting all of them using find
@andmax
andmax / nvidia_docker_save_load
Last active December 5, 2018 12:35
Copy docker containers through different machines using save and load and gzip (.tar.gz or .tgz file)
nvidia-docker save <docker-image-name> | gzip > <path-to-tgz-file>
nvidia-docker load -i <path-to-tgz-file>
@andmax
andmax / change_hostname.sh
Created December 5, 2018 12:37
Bash script to change host name
#!/usr/bin/env bash
NEW_HOSTNAME=$1
echo $NEW_HOSTNAME > /proc/sys/kernel/hostname
sed -i 's/127.0.1.1.*/127.0.1.1\t'"$NEW_HOSTNAME"'/g' /etc/hosts
echo $NEW_HOSTNAME > /etc/hostname
service hostname start
su $SUDO_USER -c "xauth add $(xauth list | sed 's/^.*\//'"$NEW_HOSTNAME"'\//g' | awk 'NR==1 {sub($1,"\"&\""); print}')"
@andmax
andmax / unison_bkp.sh
Created December 5, 2018 12:38
Backup using unison
#!/bin/bash
unison -perms 0 -rsrc false /home/andmax /media/andmax_bkp
@andmax
andmax / git_https_password_store
Created December 5, 2018 12:39
Store git https password
1- git config credential.helper store
2- git push
3- <type in password>
@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 find a previous executed command
$ history | grep <command_to_be_found>
@andmax
andmax / ssh_tunnel_config
Last active December 12, 2019 12:40
Tunnel port through ssh gateway useful for tensorboard/notebook behind a firewall
ssh -L <local-port>:<2nd-pc-address>:<2nd-pc-port> <1st-pc-address>
=
Host target-forwarding
Hostname <1st-pc-address>
User <1st-pc-username>
LocalForward <local-port> <2nd-pc-address>:<2nd-pc-port>
IdentityFile <1st-pc-identity-file>
# if unix is the gateway (1st-pc) and has its own configuration
@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>