Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

"""
Using piecewise transformations to overcome nonlinearity in storage asset optimisation.
"""
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pyomo.environ as pyo
from IPython.display import display
@Ogaday
Ogaday / compose.yaml
Last active March 6, 2024 13:54
Clickhouse in Docker
services:
warehouse:
image: clickhouse/clickhouse-server
ports:
- "8123:8123"
- "8443:8443"
- "9000:9000"
- "9440:9440"
healthcheck:
test: wget --no-verbose http://localhost:8123/
@Ogaday
Ogaday / class_logger_example.py
Created December 15, 2023 13:02
Class loggers
import logging
class Foo:
def __init__(self):
"""
>>> f = Foo()
>>> f.logger()
<Logger class_logger_example.Foo (WARNING)>
"""
@Ogaday
Ogaday / merge_with_nulls.sql
Created December 6, 2023 18:23
Clickhouse - merge with nulls
/* 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
*
*/
@Ogaday
Ogaday / deployment_data.py
Last active October 19, 2023 16:51
Get Prefect Deployment Summary
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",
@Ogaday
Ogaday / delete.py
Created October 2, 2023 07:52
Delete flow runs
# 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(
@Ogaday
Ogaday / README.md
Last active July 13, 2023 13:24
FizzBuzz implementations

FizzBuzz

The classic programming puzzle, tackled a few different ways.

Test and lint:

pip install -r requirements.txt
black --check .
flake8 *.py
@Ogaday
Ogaday / garminxwahoo.md
Created June 3, 2023 16:57
Pairing Garmin watches with Wahoo headunits
@Ogaday
Ogaday / bump.sh
Created April 6, 2023 13:55
Bump git tag
#!/bin/bash
function log_error() {
msg=$1
echo $msg >&2
}
function bump() {
target_version=$1