Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / ssh_config
Last active June 4, 2020 15:38
Good ssh configuration tips on the ~/.ssh/config file
# Strict Host Key Checking avoids know_hosts nuisances
Host *
Compression Yes
ControlMaster auto
ControlPath /tmp/ssh-%r@%h:%p
ServerAliveInterval 60
StrictHostKeyChecking no
# Adding two names to the same host server
Host name1 name2
@andmax
andmax / .emacs
Last active October 4, 2021 20:35
Good emacs definitions in ~/.emacs, ~/.emacs.d/themes/*.el
;; Set up the keyboard so the delete key on both the regular keyboard
;; and the keypad delete the character under the cursor and to the right
;; under X, instead of the default, backspace behavior.
(global-set-key [delete] 'delete-char)
(global-set-key [kp-delete] 'delete-char)
(global-set-key "\C-h" 'delete-backward-char)
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
@andmax
andmax / windows2unix
Last active June 8, 2021 17:10
Make Windows better by installing the following unix-like software
1- MobaXterm is too heavy and does not integrate well with git
2- Git bash: https://gitforwindows.org/
3- Git bash is based on mingw: http://www.mingw.org/
4- ConEmu: https://conemu.github.io/
5- ConEmu works integrated with git-bash which integrates with mingw
6- ConEmu has some display glitches with wrong line wraps
7- It may be better to use cmder "commander": https://cmder.net/
8- Cmder can be used on top of conemu, that is:
9- Cmder uses conemu as terminal and both integrates well with git-bash
10- Managing Python packages with pip can be difficult,
@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 / 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 / python2or3_start_http_server
Last active May 6, 2020 18:16
Start HTTP server in <port> (default 8000) using python2 or python3
python3 -m http.server <port>
python2 -m SimpleHTTPServer <port>