Skip to content

Instantly share code, notes, and snippets.

View VildMedPap's full-sized avatar

Sebastian Steenssøe VildMedPap

View GitHub Profile
@VildMedPap
VildMedPap / AWS_whitelist_current_IP.sh
Created May 21, 2021 13:58
AWS: Whitelist current IP address on desired ec2 and the port of your choice
INSTANCE_ID="i-xxx"
PORT=22
SG_ID=`aws ec2 describe-instance-attribute --instance-id $INSTANCE_ID --attribute groupSet | python -c "import sys, json; print(json.load(sys.stdin)['Groups'][0]['GroupId'])"`
CURRENT_IP=`curl -s http://whatismyip.akamai.com/`
aws ec2 authorize-security-group-ingress --group-id $SG_ID --protocol tcp --port $PORT --cidr $CURRENT_IP/32
@VildMedPap
VildMedPap / fetch_google_sheet.py
Created May 7, 2021 12:28
Python: Fetch data from Google Sheet
import gspread
import pandas as pd
from oauth2client.service_account import ServiceAccountCredentials
creds = ServiceAccountCredentials.from_json_keyfile_name(
filename="credentials.json",
scopes=["https://www.googleapis.com/auth/drive"]
)
# Initialize client
@VildMedPap
VildMedPap / render.py
Created May 6, 2021 20:33
Python: Render HTML in Jupyter
from IPython.core.display import display, HTML
display(HTML('<h1>Hello, world!</h1>'))
@VildMedPap
VildMedPap / autoreload.py
Created May 6, 2021 20:33
Jupyter: autoreload modules
%load_ext autoreload
%autoreload 2
@VildMedPap
VildMedPap / install_docker.sh
Created May 6, 2021 20:31
Install Docker and docker-compose on Ubuntu 20.04
# install docker
sudo apt update
sudo apt -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt update
apt-cache policy docker-ce
sudo apt -y install docker-ce
sudo chmod 666 /var/run/docker.sock
docker ps
@VildMedPap
VildMedPap / config
Created May 6, 2021 20:31
SSH Config file
Host your_short_name
User name_of_user
HostName xx.xx.xx.xx
IdentityFile ~/.ssh/name_of_your_private_ssh_key
LocalForward xxxx 127.0.0.1:xxxx