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
def pandas_dataframes_are_equal(df1, df2): | |
return list(sorted(df1.columns)) == list(sorted(df2.columns)) and \ | |
len(df1.merge(df2, how="outer", indicator=True).query("_merge!='both'"))==0 |
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
#adapted from https://gist.github.com/mlapida/931c03cce1e9e43f147b | |
import boto3 | |
tags_to_use = ['Owner'] | |
def copy_tags(): | |
instances = boto3.resource('ec2').instances.all() | |
for instance in instances: | |
tags = instance.tags | |
to_tag = [t for t in tags if t['Key'] in tags_to_use] |
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
aws s3 cp s3://ec2-instance-connect/cli/ec2instanceconnectcli-latest.tar.gz . | |
sudo pip3 install ec2instanceconnectcli-latest.tar.gz | |
mssh instanceid |
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 docker pull amazonlinux | |
sudo docker run -it amazonlinux:latest /bin/bash | |
# inside container | |
yum -y install python37 zip | |
python3 -m venv python | |
source python/bin/activate | |
pip3 install matplotlib | |
deactivate | |
rm -rf python/{bin,include,lib64,pyvenv.cfg} python/lib/python3.7/site-packages/{__pycache__,easy_install.py,numpy*,pip*,pkg_resources,setuptools*} |
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 | |
# This scripts downloads images from flickr from a search results page (flickr.html). | |
# Sketch to generate flickr.html (in Chrome): | |
# Search on flickr, select Creative Commons commercial use | |
# Change tiling to second choice (or adapt "_n" in the processing below) | |
# In Inspector (ctrl-shift-I), select top <html> element, right-click: copy element | |
# Paste into flickr.html | |
# grep image references |
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
from nbformat import v3, v4 | |
import sys | |
import os | |
infilename=sys.argv[1] | |
outfilename=os.path.splitext(infilename)[0]+".ipynb" | |
with open(infilename) as fpin: | |
text = fpin.read() | |
text=text.replace("#%%", "# <codecell>") | |
text=text.replace("# %%", "# <codecell>") |