Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am cmpadden on github.
  • I am colton (https://keybase.io/colton) on keybase.
  • I have a public key ASCwK3SQtS5XjIp74HiayYF2vH29XmcKl4wxHEnaNjw3OQo

To claim this, I am signing this object:

@cmpadden
cmpadden / csvs-to-xlsx.py
Created August 7, 2019 18:08
Convert CSVs into Excel Worksheet Tabs
"""
Convert CSVs into Excel sheets
"""
import glob
import pandas as pd
with pd.ExcelWriter("output.xlsx") as writer:
for file in glob.glob("*.csv"):
df = pd.read_csv(file)
@cmpadden
cmpadden / svg-to-pngs.sh
Created February 10, 2020 17:54
Generate common PNG sizes from an SVG
#!/bin/bash
# Generate common PNG sizes from an SVG using ImageMagick
SOURCE="example.svg"
SIZES=("16" "32" "64" "128" "256" "512" "1024")
for i in "${SIZES[@]}"; do
DESTINATION="${SOURCE/\.svg/-${i}.png}"
printf "%s\n" "Generating $DESTINATION..."
@cmpadden
cmpadden / pyspark_union_multiple_dfs.py
Created January 12, 2022 17:16
PySpark: Union Multiple Dataframes
from functools import reduce
from pyspark.sql import DataFrame, SparkSession
spark = SparkSession \
.builder \
.appName('Union DFs') \
.getOrCreate()
df1 = spark.createDataFrame(
[
@cmpadden
cmpadden / arrow-python-env.sh
Last active February 9, 2022 13:55
Apache Arrow Python Development Environment
#!/usr/bin/env bash
# Apache Arrow - Python Development Environment Configuration
###################################################################################################################
# Environment Setup #
###################################################################################################################
git clone https://github.com/apache/arrow.git
@cmpadden
cmpadden / hn-userstyle.css
Last active February 26, 2022 18:58
Opinionated Minimalist HN UserStyle
/* ==UserStyle==
@name HN Minimalist
@description Opinionated minimalist styling for Hacker News
@match *://news.ycombinator.com/*
==/UserStyle== */
/********************************************************************************
* COLORS *
********************************************************************************/
:root {
@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
@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 / 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 / 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