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
import string | |
import warnings | |
from typing import List, Dict | |
import numpy as np | |
import pandas as pd | |
def infer_dtypes(values: List, sample_size: int = 300, stop_after: int = 300): | |
""" |
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
import multiprocessing | |
import time | |
from collections import deque | |
class ThrottleBarrier(): | |
def __init__( | |
self, | |
counter: multiprocessing.Value, | |
lock: multiprocessing.Lock, |
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
import datetime | |
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor | |
from ratelimiter import ThrottleBarrier, CrossProcessesThrottle | |
def log(*args, **kwargs): | |
print(datetime.datetime.now().strftime('[%H:%M:%S]'), *args, **kwargs) | |
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 timeseries_vertices(ser:pd.Series, distance=15, coeff=3): | |
name = ser.name | |
# remove intermediate vertices on lines | |
def no_lines(df): | |
df.loc[:, 'gt_before'] = df.loc[:, name] > df.loc[:, name].shift(1) | |
df.loc[:, 'gt_after'] = df.loc[:, name] > df.loc[:, name].shift(-1) | |
df.loc[:, 'is_peak'] = df.loc[:, 'gt_before'] == df.loc[:, 'gt_after'] | |
df = df.loc[df.loc[:, 'is_peak'], :].copy() |
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
[ | |
{"side": "SELL", "tulips": 15, "tulip_price": 111.5, "transaction_date": "2022-02-01T00:00:00.250000"}, | |
{"side": "BUY", "tulips": 15, "tulip_price": 107.5, "transaction_date": "2022-02-01T00:30:00.250000"}, | |
{"side": "BUY", "tulips": 15, "tulip_price": 107, "transaction_date": "2022-02-01T01:30:00.250000"}, | |
{"side": "SELL", "tulips": 20, "tulip_price": 104.5, "transaction_date": "2022-02-01T02:00:00.250000"}, | |
{"side": "BUY", "tulips": 10, "tulip_price": 105, "transaction_date": "2022-02-01T02:00:00.250000"}, | |
{"side": "SELL", "tulips": 15, "tulip_price": 112.5, "transaction_date": "2022-02-01T03:00:00.250000"}, | |
{"side": "BUY", "tulips": 15, "tulip_price": 111.5, "transaction_date": "2022-02-01T03:30:00.250000"}, | |
{"side": "SELL", "tulips": 20, "tulip_price": 111.0, "transaction_date": "2022-02-01T04:00:00.250000"}, | |
{"side": "BUY", "tulips": 15, "tulip_price": 109.5, "transaction_date": "2022-02-01T04:30:00.250000"} |
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 python:3.7.7-slim-buster | |
RUN python -m venv /opt/venv | |
ENV PATH="/opt/venv/bin:$PATH" | |
RUN mkdir -p /usr/share/man/man1 | |
RUN apt-get update && \ | |
apt-get install -y default-jre && \ | |
apt-get -y install dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable && \ |
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
TS_DATE_FORMAT_DB_ISO = '%Y-%m-%dT%H:%M:%S,%f' # comma works for mongodb and is valid ISO | |
def datetimeindex_to_UTC(_dti): | |
dti = _dti.copy(deep=True) | |
if 'tz' not in dti or dti.tz is None: | |
dti = dti.tz_localize('UTC') | |
else: | |
dti = dti.tz_convert('UTC') | |
dti = dti.dt.strftime(TS_DATE_FORMAT_DB_ISO).astype(str).str.slice(0, -3) | |
return dti |
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
import csv | |
import os | |
from pathlib import Path | |
from typing import List | |
from databay import Outlet, Update, Record, Link | |
from databay.inlets import RandomIntInlet | |
from databay.outlet import MetadataKey | |
from databay.outlets import CsvOutlet |
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
offset = [thisComp.width, thisComp.height]/2 | |
p1 = thisComp.layer("P1").toComp([0,0]).slice(0,2) - offset | |
p2 = thisComp.layer("P2").toComp([0,0]).slice(0,2) - offset | |
t1 = thisComp.layer("T1").toComp([0,0]).slice(0,2) - offset - p1 | |
t2 = thisComp.layer("T2").toComp([0,0]).slice(0,2) - offset - p2 | |
ps = [p1, p2] | |
in_tangents = [[0,0], t2] | |
out_tangents = [t1, [0,0]] | |
createPath(ps, in_tangents, out_tangents, is_closed=false) |
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
*** Originally built for my mate Sam as part of our mentoring sessions. See: https://youtu.be/TXoDvTJuEb0 *** | |
#################### | |
WEATHER FINDER BASIC | |
#################### | |
Utilise an online weather API to fetch and display current weather information based on the city and country code provided. | |
################### |
NewerOlder