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
alias load-dotenv="set -a && source .env && set +a" |
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 datetime as dt | |
from dataclasses import dataclass | |
from typing import Callable, Generic, Optional, TypeVar, overload | |
INPUT_T = TypeVar("INPUT_T") | |
OUTPUT_T = TypeVar("OUTPUT_T") | |
class pass_thru_none(Generic[INPUT_T, OUTPUT_T]): | |
def __init__(self, func: Callable[[INPUT_T], OUTPUT_T]) -> None: |
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
class cached_property: | |
"""Decorator that converts a method into a lazy property.""" | |
# Inspired by Django and Werkzeug implementations. | |
def __init__(self, func): | |
self.func = func | |
self.name = func.__name__ | |
self.__doc__ = getattr(func, '__doc__') |
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
""" | |
Fun with Pandas Hierarchical indexing (MultiIndex) | |
================================================== | |
The examples belows shows various gotchas and corner cases when working with Pandas MultiIndex. | |
All examples use following sample data: | |
>>> import pandas as pd |
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
#!/usr/bin/env python3 | |
import argparse | |
import csv | |
import re | |
table_open_re = re.compile('<table[^>]*>', re.IGNORECASE) | |
table_close_re = re.compile('</table[^>]*>', re.IGNORECASE) | |
tr_open_re = re.compile('<tr[^>]*>', re.IGNORECASE) |
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
#!/usr/bin/env python3 | |
import argparse | |
import csv | |
import bs4 | |
def read_stream(stream, features=None): | |
soup = bs4.BeautifulSoup(stream, features=features) |
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Example Page</title> | |
<link rel="stylesheet" href="style.css"> | |
</head> | |
<body> |
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
* | |
!.gitignore |
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 datetime | |
start = datetime.date(2016, 11, 1) | |
stop = datetime.date(2016, 12, 1) | |
delta = datetime.timedelta(days=1) | |
tpl = "year=%(year)04d/month=%(month)02d/week=%(week)02d/day=%(day)02d" | |
date = start | |
while date < stop: |
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 | |
# | |
# Install generated Debian package to remote system | |
# | |
# Uploads packages directly to the target servers ignoring | |
# any repositories and installs them using `dpkg -i`. | |
# | |
# Restarts System V / Systemd services after successful installation. | |
# |