This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# On the remote | |
jupyter notebook --no-browser --port=8889 | |
# On the client | |
ssh -N -f -L localhost:8888:localhost:8889 remote_user@remote_host | |
# The first option -N tells SSH that no remote commands will be executed and is useful for port forwarding. | |
# The second option -f has the effect that SSH will go to background, | |
# The last option -L lists the port forwarding configuration (remote port 8889 to local port 8888). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import aiohttp | |
from aiohttp import web | |
import json | |
WEBSITES = ['http://example.com/', 'http://dummy-a98x3.org', 'http://example.net/'] | |
async def handle(request): | |
# Fire up 3 requests in parallel | |
coroutines = [aiohttp.request('get', website) for website in WEBSITES] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Installing solorized theme for terminator | |
git clone https://github.com/ghuntley/terminator-solarized.git | |
cd terminator-solarized | |
mkdir -p ~/.config/terminator/ | |
touch ~/.config/terminator/config | |
# if you want to replace current config: | |
cp config ~/.config/terminator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install powerline # install powerline fonts for ubuntu > 14.04 useful of oh-my-zsh themes |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo mount -o uid=pi,gid=pi /dev/sda1 /mnt/ # mount with pi permission |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To include in notebook for inline ggplot with bigger size | |
%matplotlib inline | |
import matplotlib.pyplot as plt | |
plt.rcParams['figure.figsize'] = (12, 8) # bigger figsize | |
plt.style.use('ggplot') # ggplot2 style for matplotlib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
# logging.getLogger(type(self).__name__) if you have a lot of class | |
log = logging.getLogger() # 'root' Logger | |
console = logging.StreamHandler() # logging to console | |
csv_handler = logging.FileHandler('logs.csv') | |
template_log = '%(asctime)s,%(levelname)s,%(processName)s,%(filename)s,%(lineno)s,%(message)s' #csv | |
console.setFormatter(logging.Formatter(template_log)) | |
log.addHandler(console) # prints to console. | |
log.addHandler(csv_handler) # save to csv gile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$SUDO_USER" ]; then | |
echo "$0 must be called from sudo. Try: 'sudo ${0}'" | |
exit 1 | |
fi | |
SCRIPT_LOCATION="/etc/network/if-up.d/reverse_ssh_tunnel" | |
echo "Creating file in $SCRIPT_LOCATION" | |
echo "Installing openssh-server and autossh" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You need a server acessible from the client and server (aws instance for example accessible on port ssh 22 ) | |
# install autossh ( apt-get install autossh) | |
# on the local machine (raspberry pi ) | |
autossh -M 10001 -f -N -R 10000:localhost:22 user@serverip | |
# -n Redirects stdin from /dev/null (actually, prevents reading from stdin). This must be used when ssh is run in the background | |
# -N Do not execute a remote command. This is useful for just forwarding ports | |
# -T Do not allocate a pseudo-tty on the remote system | |
# -R Set up the tunnel as a reverse tunnel. |