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 argparse | |
def main(*args, **kwargs): | |
print('\n'.join(args)) | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser( | |
description=__doc__, | |
formatter_class=argparse.RawDescriptionHelpFormatter, | |
) |
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
sudo apt-get update | |
sudo apt-get install python3-setuptools python3-dev build-essential | |
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py | |
sudo python3 get-pip.py |
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
# -*- coding: utf-8 -*- | |
import os | |
import numpy as np | |
import requests | |
import sys | |
if (sys.version_info.major + sys.version_info.minor / 10) < 3.6: | |
raise SystemError('push.py uses f-strings. Please install python 3.6+') | |
from slackclient import SlackClient | |
SLACK_TOKEN = os.environ['SLACK_TOKEN'] |
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
# https://linuxize.com/post/how-to-install-and-configure-squid-proxy-on-ubuntu-20-04/ | |
# Install squid | |
sudo apt update | |
sudo apt install squid | |
# Backup config | |
sudo cp /etc/squid/squid.conf{,.orginal} | |
# Add allowed IPs |
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
# Website location: | |
# /var/www/html | |
# Config file location: | |
# /etc/nginx/nginx.conf | |
# Install | |
sudo apt-get update | |
sudo apt-get install nginx | |
sudo service nginx restart |
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
# Creating a virtual env kernel | |
# ----------------------------- | |
$ python -m venv .venv | |
$ source .venv/bin/activate | |
(.venv) $ pip install ipykernel | |
(.venv) $ python -m ipykernel install --user --name=proj-name | |
# Managing the kernel | |
# ----------------------------- | |
$ jupyter kernelspec list |
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
# File path: | |
# ~/.jupyter/jupyter_notebook_config.py | |
import os | |
from subprocess import check_call | |
import datetime | |
import re | |
def timestamped_file(fname): | |
return bool(re.match('.*\d{4}-\d{2}-\d{2}\.ipynb', fname)) |
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 init_logging(level='debug'): | |
import logging | |
import os | |
import datetime | |
from pytz import timezone | |
if level == 'debug': | |
LOGGING_LEVEL = logging.DEBUG | |
elif level == 'info': | |
LOGGING_LEVEL = logging.INFO |
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 | |
def dump_jsonl(data, output_path, append=False): | |
""" | |
Write list of objects to a JSON lines file. | |
""" | |
mode = 'a+' if append else 'w' | |
with open(output_path, mode, encoding='utf-8') as f: | |
for line in data: | |
json_record = json.dumps(line, ensure_ascii=False) |
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
season | game_number | team_name | date | pull_period | pull_time | goal_for_time | goal_against_time | goal_for_timedelta | goal_against_timedelta | game_end_timedelta | |
---|---|---|---|---|---|---|---|---|---|---|---|
20032004 | 710 | CHI | 2004-01-21 | 3 | 0 days 00:19:44.000000000 | 0 days 00:19:47.000000000 | 0 days 00:00:03.000000000 | ||||
20032004 | 205 | MIN | 2003-11-08 | 3 | 0 days 00:19:58.000000000 | 0 days 00:00:02.000000000 | |||||
20032004 | 1230 | S.J | 2004-04-04 | 3 | 0 days 00:18:39.000000000 | 0 days 00:19:40.000000000 | 0 days 00:01:01.000000000 | ||||
20032004 | 655 | PHX | 2004-01-13 | 3 | 0 days 00:19:03.000000000 | 0 days 00:19:25.000000000 | 0 days 00:00:22.000000000 |