Skip to content

Instantly share code, notes, and snippets.

@Gerenuk
Gerenuk / print_lambda.py
Last active August 4, 2022 11:02
Print graphical lambda calculus
from arpeggio.cleanpeg import ParserPEG
from arpeggio import PTNodeVisitor, visit_parse_tree
GRAMMAR=r"""
full = expr EOF
expr = var / function / application
function = "/" var "." expr
application = "(" expr expr ")"
var = r"\w+"
"""
import re
import unicodedata
STATE_FIND_STREETNAME = 1
STATE_FIND_FIRST_NUMBER = 2
STATE_FIND_SECOND_NUMBER = 3
STATE_ALL_FOUND = 4
def normalize_street(
@Gerenuk
Gerenuk / HauntedPirates
Created May 22, 2020 19:39
Haunted Pirates Bots
#!/usr/bin/env python
import contextlib as __stickytape_contextlib
@__stickytape_contextlib.contextmanager
def __stickytape_temporary_dir():
import tempfile
import shutil
dir_path = tempfile.mkdtemp()
@Gerenuk
Gerenuk / FleeingMiner
Last active May 22, 2020 15:38
Miner trying to flee from Pirates
#!/usr/bin/env python
import contextlib as __stickytape_contextlib
@__stickytape_contextlib.contextmanager
def __stickytape_temporary_dir():
import tempfile
import shutil
dir_path = tempfile.mkdtemp()
:toc:
:toc-placement: left
toc::[]
== Summary
* mostly from https://otexts.org/fpp2/[Forecasting: Principles and Practice (Hyndman, Athanasopoulos)]
* "stationary": properties do not depend on absolute time (e.g. fixed time seasons; but may have cycles due to dependence on past values)
* centered moving average will smooth out seasons (e.g. 1/8,1/4,1/4,1/4,1/8)
* maybe transform data if want to restrict to range (e.g. log for positive values) or variances are changing (e.g. Box-Cox transform)
@Gerenuk
Gerenuk / gist:327746121156437941f478b3724c03d7
Last active December 21, 2017 22:34
Interpretation of a Monoid in Python
from functools import reduce
from operator import add
def monoid(combine, create=lambda x:x):
def wrapped(val):
return Monoid(combine, create(val))
return wrapped