Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
from functools import reduce
from itertools import repeat
import numpy as np
# https://fivethirtyeight.com/features/can-the-riddler-bros-beat-joe-dimaggios-hitting-streak/
AT_BATS_PER_GAME = 4
@harryposner
harryposner / recession_bars.py
Last active August 27, 2021 01:54
Add NBER recession bars to Matplotlib axes for time series plots
"""MIT License
Copyright (c) 2019-2021 Harry Posner
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@harryposner
harryposner / stack_calculator.py
Last active May 12, 2020 21:01
Quick and dirty stack calculator
#!/usr/bin/env python3
import math
import operator as op
import os
import readline
import statistics
import sys
from functools import reduce
@harryposner
harryposner / remove_script_tags.py
Created June 24, 2020 17:34
Remove <script> tags from HTML files
#!/usr/bin/env python3
"""Remove <script> tags from HTML files
Usage: `remove_script_tags [path]`
If `path` is a directory, will process all `.html` files in the
directory recursively.
"""
@harryposner
harryposner / get_nyt_xword.py
Last active April 11, 2024 21:09
Scrape NYT crossword puzzles in AcrossLite format from xwordinfo.com
#!/usr/bin/env python3
"""Scrape NYT crossword puzzles in AcrossLite format from xwordinfo.com
Usage: ./get_nyt_xword.py [puzzle-iso-date] filename
"""
import re
import sys
import datetime
@harryposner
harryposner / flake.nix
Created October 22, 2022 22:32
Nix flake for Raspberry Pi Pico projects using C
{
description = "Raspberry Pi Pico projects";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = import nixpkgs { inherit system; };
in