Skip to content

Instantly share code, notes, and snippets.

View haydenflinner's full-sized avatar

Hayden Flinner haydenflinner

  • NYC
View GitHub Profile
@haydenflinner
haydenflinner / tasks.py
Created September 22, 2018 15:31
A pyinoke tasks.py that implements make-like file dependencies.
from invoke import task, Collection
import invoke
import functools, itertools
import structlog
import os
log = structlog.get_logger()
def create_timestamp_differ(file_outputs_query, file_inputs_query, precursor=None):
"""
@haydenflinner
haydenflinner / doc.md
Created September 23, 2018 23:00
invoke-magic.md

This decorator is used to derive parameters to your function from the ctx argument to the function. This is best shown by example. Suppose this configuration:

    ctx = {
        "myfuncname" : {
            "param1" : 392,
            "namedparam1" : 199
        }
 }
@haydenflinner
haydenflinner / maketask.md
Last active September 25, 2018 01:16
maketask.md

An invoke.task replacement that supports make-like file dependencies.

make_task works just like GNU-make: by checking the timestamps on the last update of each file that you depend on against the timestamp of the files you create, we can decide whether or not you need to run.

@param outputs: List of strings that will be used to index into your ctx to determine the filepath that you output to. Example:

@haydenflinner
haydenflinner / drain.py
Created October 15, 2022 15:55
A cmd-line application that automatically translates text logs to parsed CSVs. Open your logs in visidata!
#!/usr/bin/env python
# Original source here, see that repo for other algos and links to papers.
# https://github.com/logpai/logparser
"""
Example usage of this cmdline program:
python drain.py mylogfile.log | vd -f csv
Hints:
Use , key (with cursor in template column) to select all rows like this one.
Then press " to open a new temporary page with only those rows,
@haydenflinner
haydenflinner / stats.py
Created January 17, 2024 12:38
Pandas code for modelling live race timing + statistical insight from it
import pandas as pd
from dataclasses import dataclass
@dataclass
class PositionSample:
lap: int
rider: str
pos: int
Sample = PositionSample