Skip to content

Instantly share code, notes, and snippets.

View Menziess's full-sized avatar

Stefan Schenk Menziess

View GitHub Profile
from tslearn.clustering import TimeSeriesKMeans
from tslearn.utils import to_time_series_dataset
import pandas as pd
data = [
[0, 1, 2, 3, 4],
[1, 2, 3, 4, 0],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[5, 6, 3, 4, 0],
class DirectedGraph:
"""A basic implementation of a directed graph."""
def __init__(self):
self.graph = {}
def add_node(self, node):
if node not in self.graph:
self.graph[node] = {}
from datetime import datetime as dt, timezone
from re import match
from toolz.curried import curry
DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
DATE_FORMAT = '%Y-%m-%d'
@curry
from itertools import groupby, islice
from typing import Iterable, cast
from toolz.curried import curry, map, pluck
def batched(iterable, n):
"""Batch data into tuples of length n.
>>> list(batched('ABCDEF', 3))
from typing import Iterable
def dict_diff(
old: dict,
new: dict,
ignore_keys: Iterable[str] = [],
include_keys: Iterable[str] = []
) -> dict:
"""Capture changes between dictionaries.
from datetime import date
from datetime import datetime as dt
from typing import Union, cast
from dateutil.tz import tzlocal, tzutc
DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
def int_to_timestamp(
from time import sleep
from typing import Any
def retry(f, *args, _retries: int = 3, _sleep: float = 0.0, **kwargs) -> Any:
"""Retry function call until it succeeds."""
if _retries < 0:
raise ValueError('_retries cannot be negative.')
tries = _retries + 1
for attempt in range(tries):
try:
import sys
import logging
logger = logging.getLogger(__file__)
def handle_exception(exc_type, exc_value, exc_traceback):
"""Can be assigned to sys.excepthook to log uncaught exceptions."""
if issubclass(exc_type, KeyboardInterrupt):
sys.__excepthook__(exc_type, exc_value, exc_traceback)
name: $(BuildID)
trigger:
- master
- feature/*
- refs/tags/*
variables:
${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags/') }}:
group: prd
/bin/kafka-topics --bootstrap-server localhost:9091 --list
/bin/kafka-topics --bootstrap-server localhost:9091 --create --topic lol
/bin/kafka-topics --bootstrap-server localhost:9091 --delete --topic lol
/bin/kafka-console-consumer --bootstrap-server localhost:9091 --topic lol --from-beginning
/bin/kafka-console-producer --bootstrap-server localhost:9091 --topic lol