View filters.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
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# >> | |
# vidangel-backend, 2022 | |
# Blake VandeMerwe <blake@vidangel.com> | |
# << | |
import re | |
from datetime import timedelta |
View base_query_validator.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
from inspect import signature | |
from http import HTTPStatus | |
from logging import getLogger | |
from functools import wraps, partial | |
from typing import Dict, Callable, TypeVar, Optional | |
from fastapi import HTTPException | |
from fastapi.params import Query | |
T = TypeVar('T') |
View display.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
import time | |
from typing import Optional, List | |
from PIL import Image | |
from PIL import ImageDraw | |
from PIL import ImageOps | |
from PIL import ImageFont | |
from smbus import SMBus |
View r-pihole_top10.txt
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
# Compilation of r/pihole User's Top-10 blocked domains. | |
ssl-bbcsmarttv.2cnt.net | |
tlx.3lift.com | |
graph.accountkit.com | |
app.adjust.com | |
ib.adnxs.com | |
fls-na.amazon.com | |
mads.amazon.com | |
unagi-na.amazon.com |
View map_join_str.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
import timeit | |
print(timeit.Timer("'+'.join([str(x) for x in range(10000)])").repeat(3, 1000)) | |
print(timeit.Timer("'+'.join(map(str, range(10000)))").repeat(3, 1000)) | |
# [1.843802978983149, 1.838354193023406, 1.8291272450005636] | |
# [1.4447947760345414, 1.442527316045016, 1.4384180280612782] |
View gist.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
import os | |
import subprocess | |
def in_container(): | |
# type: () -> bool | |
""" Determines if we're running in an lxc/docker container. """ | |
out = subprocess.check_output('cat /proc/1/sched', shell=True) | |
out = out.decode('utf-8').lower() | |
checks = [ | |
'docker' in out, |
View only_if.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
import time | |
import json | |
import random | |
from functools import wraps | |
def only_if(condition, args_=None, *, pass_value=False, cache=False): | |
_fn = condition if callable(condition) else lambda: condition | |
if args_ is None: |
View slack_handler.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
import os | |
import time | |
import json | |
import socket | |
import logging | |
from slacker import Slacker, Error as SlackerError | |
class SlackChannelHandler(logging.Handler): |
View cc_extras.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
import os | |
import re | |
RE_CONTENT = re.compile(r'(\|[\w\.\,]+\|)', re.I) | |
fns = { | |
'blockquote': lambda s: '> ' + s, | |
'code': lambda s: ' ' + s, | |
'comment': lambda s: '# {}'.format(s).rstrip() + '\n', | |
'list': lambda s: ' - ' + s |
View scratch.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
import string | |
from selenium.webdriver import Chrome | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.support.ui import Select | |
CSS = By.CSS_SELECTOR | |
def split_case(n): | |
ret = [] |
NewerOlder