Skip to content

Instantly share code, notes, and snippets.

View ericfourrier's full-sized avatar
🦉
Building neat tools to secure cloud and source code

Eric Fourrier ericfourrier

🦉
Building neat tools to secure cloud and source code
View GitHub Profile
# 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).
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]
# 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
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.
sudo mount -o uid=pi,gid=pi /dev/sda1 /mnt/ # mount with pi permission
# 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
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
#!/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"
# 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.