Skip to content

Instantly share code, notes, and snippets.

View bretttolbert's full-sized avatar

Brett Tolbert bretttolbert

View GitHub Profile
@bretttolbert
bretttolbert / statesplot_multicolor.py
Last active October 3, 2025 00:52
statesplot_multicolor.py
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
import geopandas as gpd
import fiona
import numpy as np
fiona.drvsupport.supported_drivers["KML"] = "rw"
title = "Title"
override_bucket0_color = "lightgrey" # set to None to use colormap color
@bretttolbert
bretttolbert / statesplot.py
Last active October 3, 2025 00:27
US states plot
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
import geopandas as gpd
import fiona
fiona.drvsupport.supported_drivers["KML"] = "rw"
# Load detailed US states data from the U.S. Census Bureau
# Source: https://www2.census.gov/geo/tiger/GENZ2022/shp/cb_2022_us_state_20m.zip
states = gpd.read_file(
@bretttolbert
bretttolbert / inequality.py
Created September 30, 2025 04:12
Wealth Inequality vs GDP per Capita by Country scatter plot
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from typing import List
def is_year(s: str):
try:
value = int(s)
return value >= 1960
@bretttolbert
bretttolbert / CoversToVid.py
Last active October 2, 2023 23:24
Copy all cover.jpg from music library and generate video with ffmpeg
#!/usr/bin/env python3
import os
import time
MUSIC_DIR="/data/Music/"
COVERS_DIR="/data/Covers/"
COVER_VIDEO_FILE="covers.mp4"
OUTPUT_VIDEO_FILE="output.mp4"
WARNING_IMAGE_FILE="warning.jpg"
WARNING_VIDEO_FILE="warning.mp4"
@bretttolbert
bretttolbert / rsync-all-kodi.sh
Created July 11, 2023 03:22
Script I use to rsync my music and music videos to my two Kodi servers (I use samba shares on a separate file server for my TV shows and movies)
#!/bin/bash
LIVING_ROOM_IP=192.168.0.186
BASEMENT_GYM_IP=192.168.0.159
# $1 = Kodi server IP address
rsync_music_videos_kodi () {
rsync -ahPv /data/MusicVideos/ root@$1:/storage/musicvideos/ \
--delete --prune-empty-dirs
}
@bretttolbert
bretttolbert / NukeWisconsin.sh
Created July 6, 2023 00:34
Example: Make a music video by downloading a YouTube video and using ffmpeg to combine it with an mp3 audio file
#!/bin/bash
# Nuke Wisconsin - Music Video Generator Example
VIDURL="https://www.youtube.com/watch?v=Pq6yMDBOcuI"
youtube-dl -k -f 'bestvideo[fps<=30]+bestaudio' $VIDURL
INVID="Chinese Nuclear Testing Film (1966)-Pq6yMDBOcuI.f135.mp4"
INAUD="The Crucifucks - The Savior.mp3"
STARTTIME="00:10:00"
OUTVID="1987 - Crucifucks - The Savior.mp4"
ffmpeg -ss "$STARTTIME" -i "$INVID" -i "$INAUD" -shortest -y "$OUTVID"
import pandas as pd
office = 'DEMCNG0007UNITED STATES REPRESENTATIVE'
csv_filename = '2006PrimaryElectionResults.csv'
# Data source:
# https://data.indy.gov/search?q=elections%20results%20
# specifically:
# https://xmaps.indy.gov/ODP/Download/Elections/2006PrimaryElectionResults.xls (needs to be converted to to CSV)
@bretttolbert
bretttolbert / gist:ea7b0efe6eafa6da629a29e915b57e5a
Last active December 12, 2025 03:47
Political Ideologies Tree Graph (graphviz dot file)
digraph D {
edge [arrowhead=normal, color=black]
Ideology -> {Other, Left, Right}
Other -> {AnarchoPrimitivism}
Left -> {Anarchism, Socialism, Liberalism}
Liberalism -> {SocialDemocracy}
Right -> {Neoliberalism, Libertarianism, Conservatism, Monarchism, Fascism}
Fascism -> NazBols
Libertarianism -> AnarchoCapitalism
edge [arrowhead=onormal, color=orange]
@bretttolbert
bretttolbert / pretty_print_json.py
Created December 18, 2017 02:29
Pretty print JSON
import json
data = {'x': [1,2,3], 'y': 4, 'z': 5}
json_str = json.dumps(data, sort_keys=True, indent=4, separators=(',', ': '))
print(json_str)