The classic programming puzzle, tackled a few different ways.
Test and lint:
pip install -r requirements.txt
black --check .
flake8 *.py| /* Outer Merges with Nulls in ClickHouse | |
| * | |
| * By default, outer merges in clickhouse will produce _interesting_ defualt | |
| * values for empty cells in an outer join. This query demonstrates how to | |
| * configure clickhouse to use nulls for missing values, as in the SQL | |
| * standard. | |
| * | |
| * See: https://clickhouse.com/docs/en/operations/settings/settings#join_use_nulls | |
| * | |
| */ |
| from typing import Optional | |
| import pandas as pd | |
| from prefect.client.orchestration import get_client | |
| from pydantic import BaseModel | |
| columns = { | |
| "flow_name": "Flow", | |
| "deployment_name": "Deployment", | |
| "schedule": "Schedule", |
| # In IPython: | |
| from prefect.client.orchestration import get_client | |
| from prefect.server.schemas.filters import FlowRunFilter, FlowRunFilterState, FlowRunFilterStateName, FlowRunFilterStartTime, FlowFilterName, FlowFilter, FlowFilterId | |
| async with get_client() as client: | |
| flow = await client.read_flow_by_name("flow-name") | |
| async with get_client() as client: | |
| flow_runs = await client.read_flow_runs( |
Garmin watches can broadcast heartrate over ant+ eg. forerunner 235
Wahoo units can receive heartrate data from ant+. See.
See also:
| #!/bin/bash | |
| function log_error() { | |
| msg=$1 | |
| echo $msg >&2 | |
| } | |
| function bump() { | |
| target_version=$1 |
| #!/usr/bin/env python3 | |
| """Utility to produce the hash of a collection of file and directory paths. | |
| Usage:: | |
| ./hash_paths.py --help | |
| """ | |
| import argparse | |
| import hashlib | |
| import io |
| """ | |
| """ | |
| from argparse import ArgumentParser | |
| from artifacts_keyring import CredentialProvider # type: ignore | |
| def get_artifact_token(organization: str, feed: str) -> str: | |
| """Get credentials for an azure artifacts feed.""" | |
| provider = CredentialProvider() |
| """ | |
| Utilities for weighted means on DataFrames. | |
| """ | |
| from functools import partial | |
| from typing import Callable | |
| import pandas as pd | |
| def weighted_mean(frame: pd.DataFrame, value_col: str, weight_col: str) -> float: |
| """An example of table reflection with SQLAlchemy. | |
| Test with Python 3.10 & SQLAlchemy 2.0. | |
| See: https://stackoverflow.com/a/75389730/4244912 | |
| """ | |
| from sqlalchemy import Table, create_engine, text | |
| from sqlalchemy.orm import DeclarativeBase, Session | |
| # Create a SQLAlchemy engine connected to an in-memory SQLite3 DB: |