Skip to content

Instantly share code, notes, and snippets.

$ python -c "import math; [print(1/(math.sqrt(n))) for n in range(1, 1000)]" | uplot line -t "1/sqrt(n)"
1/sqrt(n)
┌────────────────────────────────────────┐
1 │⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
@cmpadden
cmpadden / dagster-example-map-reduce-graph-asset.py
Created July 2, 2024 15:27
dagster-example-map-reduce-graph-asset.py
"""
dagster dev -f dagster-example-map-reduce-graph-asset.py
"""
from itertools import chain
from dagster import Definitions, DynamicOut, DynamicOutput, asset, graph_asset, op
@asset
@cmpadden
cmpadden / midi-to-audio-backed-mp4.sh
Created June 29, 2024 03:45
Convert midi files to instrument backed video
#!/bin/bash
TARGET_MIDI_FILE="bk_cove.mid"
STATIC_COVER_IMAGE="${HOME}/Downloads/bk_cover_image.jpg"
# open midi file in Logic Pro
open "$TARGET_MIDI_FILE"
# use `osascript` to bounce the project, converting midi tracks to an audio file
osascript \
@cmpadden
cmpadden / example-asset-check-iomanager.py
Created June 25, 2024 19:59
Dagster: Example of `@asset_check` with custom `IOManager`
USAGE
$ dagster dev -f example-asset-check-iomanager.py
"""
from dagster import (
AssetCheckResult,
Definitions,
@cmpadden
cmpadden / git-project-remote-origin-urls.py
Created June 10, 2024 18:32
Extracts git origin remote URLs for all repositories in a project directory.
"""Extracts git origin remote URLs for all git repositories in `TARGET_DIRECTORY`.
This is useful if you would like to get a list of repositories from a project directory that you
would like to clone elsewhere.
"""
import configparser
import os
@cmpadden
cmpadden / rename-epub-library.py
Created May 4, 2024 23:45
Rename epub library from metadata
"""Renames epub files using title and author(s) present in metadata."""
import ebookmeta
import os
import shutil
from glob import glob
SOURCE_DIRECTORY = os.path.expanduser("~/Desktop/Books/")
DESTINATION_DIRECTORY = os.path.expanduser("~/Desktop/Library/")
@cmpadden
cmpadden / export-epubs.sh
Created May 1, 2024 02:38
Export Apple Books ePubs
#!/bin/bash
destination="/Users/colton/Desktop/Library"
mkdir -p "$destination"
cd /Users/colton/Library/Mobile Documents/iCloud~com~apple~iBooks/Documents
for i in *.epub; do
pushd "$i"
zip --quiet -X0 "$destination/$i" mimetype
@cmpadden
cmpadden / dmv-rapidpass-locations.py
Last active April 13, 2024 21:33
DMV Rapidpass Locations
"""Leaflet map of all DMV Rapidpass locations.
The rapidpassvirginia website provides invidiual links to latitude/longitude points on a Google map,
making it very difficult to find the most ideal location for a rapid pass emmissions inspection.
This script pulls the data from their website with `pd.read_html`, and plots it on a map using the
`folium` library.
PREREQUISITES
pip install pandas folium
@cmpadden
cmpadden / openai-list-models.sh
Created August 4, 2023 19:41
List OpenAI Models
#!/bin/bash
models=$(curl -s https://api.openai.com/v1/models -H "Authorization: Bearer $OPENAI_API_KEY")
jq .data[].id <(echo "$models") | sort -u
@cmpadden
cmpadden / chatblade-programmer-example.sh
Last active June 5, 2023 14:52
Chatblade Custom Prompt Example
mkdir -p ~/.config/chatblade
# create a custom prompt for programming
echo "You are a helpful but succinct chatbot that assists an impatient \
programmer by directly answering questions. You understand that the \
programmer is advanced enough to understand succinct phrases and prefers \
direct answers with little boilerplate." >> ~/.config/chatblade/programmer
# interactive use of custom prompt
chatblade -i -p programmer