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
// ==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 = [
git name-rev --tags --name-only <SHA>
@MarcoGorelli
MarcoGorelli / m6_scoring.sql
Created October 1, 2024 11:09
m6 scoring in sql
WITH unique_symbols AS (
SELECT DISTINCT symbol
FROM df
),
unique_dates AS (
SELECT DISTINCT date
FROM df
),
all_rows AS (
SELECT *
@MarcoGorelli
MarcoGorelli / get_size_of.py
Last active September 3, 2024 13:26
get_size_of.py
"""
Example usage:
python3 get_size_of.py polars altair
"""
import sys
import subprocess
import os
args = ' '.join(sys.argv[1:])
@MarcoGorelli
MarcoGorelli / time_add_lags.py
Last active June 17, 2024 08:48
add_lags timing
import polars as pl
import numpy as np
from sklego.pandas_utils import add_lags
rng = np.random.default_rng(1)
N = 10_000_000
a = rng.integers(0, 10, size=N)
b = rng.integers(0, 10, size=N)
c = rng.integers(0, 10, size=N)
df = pl.DataFrame({'a': a, 'b': b, 'c': c})
@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