This file contains 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 -eu | |
sudo apt-get update | |
echo "Installing docker" | |
sudo apt-get -y install apt-transport-https | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo apt-key fingerprint 0EBFCD88 | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get update |
This file contains 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
# Dependencies to make "headless" chrome/selenium work: | |
sudo apt-get -y install xvfb gtk2-engines-pixbuf | |
sudo apt-get -y install xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable | |
echo "Starting X virtual framebuffer (Xvfb) in background..." | |
Xvfb -ac :99 -screen 0 1280x1024x16 & | |
export DISPLAY=:99 |
This file contains 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 json | |
import datetime | |
'''Create an encoder subclassing JSON.encoder. | |
Make this encoder aware of our classes (e.g. datetime.datetime objects) | |
''' | |
class Encoder(json.JSONEncoder): | |
def default(self, obj): | |
if isinstance(obj, datetime): | |
return obj.isoformat() |
This file contains 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 pretty_request(request): | |
headers = '' | |
for header, value in request.META.items(): | |
if not header.startswith('HTTP'): | |
continue | |
header = '-'.join([h.capitalize() for h in header[5:].lower().split('_')]) | |
headers += '{}: {}\n'.format(header, value) | |
return ( |