Skip to content

Instantly share code, notes, and snippets.

View MarcoGorelli's full-sized avatar
raise the alarm, climate emergency!

Marco Edward Gorelli MarcoGorelli

raise the alarm, climate emergency!
View GitHub Profile
@MarcoGorelli
MarcoGorelli / gist:0ceb13ab902153a81e6c2d02f4c9a037
Created January 28, 2024 12:35
running polars rust tests example
cargo test --package polars --test it --all-features -- core::pivot::test_pivot_new
@MarcoGorelli
MarcoGorelli / t.py
Created December 1, 2023 14:23
nested pie charts
import matplotlib.pyplot as plt
from matplotlib.cm import get_cmap
import numpy as np
fig, ax = plt.subplots()
timings = np.array([11, 360, 573, 758])
total_timings = np.vstack([timings, 1000 - timings])
inner = total_timings[:, 0]
mid = total_timings[:, 1]
@MarcoGorelli
MarcoGorelli / find_bad_docstring_bullet_points.py
Last active January 29, 2024 09:50
find bad docstring bullet points
# ruff: noqa
import sys
"""
Find cases where docstring bullet points will not render correctly in the documentation.
Do this:
```
Here is a list of things:
- thing 1
- thing 2
@MarcoGorelli
MarcoGorelli / docstring_checker.py
Created August 6, 2023 09:35
docstring-checker
if __name__ == "__main__":
files = subprocess.run(
["git", "ls-files"], capture_output=True, text=True
).stdout.split()
ret = 0
for file in files:
if not file.endswith(".py"):
continue
with open(file) as fd:
content = fd.read()
@MarcoGorelli
MarcoGorelli / just-make-it-anew.sh
Last active September 23, 2023 13:49
just-make-it-anew.sh
deactivate
cp bytecode-parsing-tests.sh ../../temporary-polars-files/
cp just-make-it-anew.sh ../../temporary-polars-files/
cp pre-commit.sh ../../temporary-polars-files/
cp repl.sh ../../temporary-polars-files/
cp ../.vscode/settings.json ../../temporary-polars-files/
git clean -fxfd ../.
cargo clean
rustup self uninstall
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ipython -i -c 'import pandas as pd; \
from pandas.core.arrays import *; \
import polars as pl; \
from datetime import datetime, timezone, timedelta; \
from pandas._libs.tslibs.parsing import guess_datetime_format; \
from dateutil.parser import parse as du_parse; \
import datetime as dt; \
import numpy as np; \
from pandas import *; \
import pandas; \
// ==UserScript==
// @name myshipit
// @author marcogorelli
// @match https://github.com/*
// adapted from https://github.com/chriskuehl/shipit/blob/master/shipit.user.js,
// but I removed a handful of gifs (like the pikachu one) which I didn't like
// ==/UserScript==
(function () {
var urls = [
# usage:
# python -m cProfile -o out.prof perf.py
# snakeviz out.prof --server
import pandas as pd
dates = pd.date_range("1900", "2000").tz_localize("+01:00").strftime("%Y-%d-%m %H:%M:%S%z").tolist()
dates.append("2020-01-01 00:00:00+02:00")
def main():
import sys
import subprocess
import re
import shlex
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('command')
parser.add_argument('action', choices=['pull', 'push'])
args = parser.parse_args()
import bornly as bns
import numpy as np
import pandas as pd
from pmdarima import auto_arima
from statsmodels.tsa.statespace.sarimax import SARIMAX
flights = bns.load_dataset("flights")
flights["t"] = np.arange(len(flights))
PERIOD = 12
n_steps = 12