Skip to content

Instantly share code, notes, and snippets.

@thomascamminady
thomascamminady / fitparser.py
Created February 14, 2025 08:11
Parse .fit files
# /// script
# dependencies = [
# "fire",
# "polars",
# "garmin-fit-sdk",
# ]
# ///
from __future__ import annotations
import logging
@thomascamminady
thomascamminady / run_query_against_redshift.py
Created February 11, 2025 11:59
Run Metabase queries in the command line
# /// script
# dependencies = [
# "fire",
# "polars",
# "rich",
# "redshift_connector",
# ]
# ///
import json
{
"config": {
"text": {
"color": "gray",
"fontSize": 14
},
"title": {
"anchor": "middle",
"fontWeight": "normal",
"titleFontWeight": "normal",
```
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"background": "white",
"padding": 5,
"width": 480,
"data": [
{
"name": "brush_store"
},
year day color count
2015 25 gold 6695
2015 25 silver 2534
2015 24 gold 7727
2015 24 silver 105
2015 23 gold 8999
2015 23 silver 44
2015 22 gold 7378
2015 22 silver 199
2015 21 gold 9662
# %%
import numpy as np
import matplotlib.pyplot as plt
from cycler import cycler
import matplotlib.patheffects as path_effects
# %%
np.random.seed(1)
n, m = 200, 6
x = np.arange(n)
@thomascamminady
thomascamminady / drop_columns_that_are_all_null.py
Created September 20, 2023 07:40
Polars drop columns that are all null
import polars as pl
def drop_columns_that_are_all_null(_df: pl.DataFrame) -> pl.DataFrame:
return _df[[s.name for s in _df if not (s.null_count() == _df.height)]]
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"background": "white",
"padding": 5,
"title": {"anchor": "middle", "text": "World Record Progression"},
"data": [
{"name": "param_13_store"},
{"name": "param_14_store"},
{
"name": "data-f0a84751744be4555114288140dc4b49",
@thomascamminady
thomascamminady / json
Created June 6, 2023 12:21
World Record Data
{
"date of event": {
"0": -38275200000,
"1": 84240000000,
"2": 203472000000,
"3": 207100800000,
"4": 236563200000,
"5": 423878400000,
"6": 426038400000,
"7": 461980800000,
@thomascamminady
thomascamminady / csv
Created June 6, 2023 12:19
World Records
,date of event,percent of wr,event,sex,name,rank
0,1968-10-15,105.62440419447093,100 metres,Female,Wyomia Tyus,2501
1,1972-09-02,105.52907530981888,100 metres,Female,Renate Stecher,2293
2,1976-06-13,105.24308865586272,100 metres,Female,Ingeborg Helten,1774
3,1976-07-25,104.95710200190658,100 metres,Female,Annegret Richter,1362
4,1977-07-01,103.71782650142993,100 metres,Female,Marlies Göhr,338
5,1983-06-08,103.05052430886559,100 metres,Female,Marlies Göhr,130
6,1983-07-03,102.85986653956148,100 metres,Female,Evelyn Ashford,104
7,1984-08-22,102.57387988560534,100 metres,Female,Evelyn Ashford,67
8,1988-07-16,100.0,100 metres,Female,Florence Griffith-Joyner,1