Skip to content

Instantly share code, notes, and snippets.

@mchapman87501
mchapman87501 / plot_monthly_inflation.py
Last active September 13, 2022 18:31
Plot month-to-month inflation using data from https://download.bls.gov/pub/time.series/cu/
#!/usr/bin/env python
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
data = pd.read_csv("data/cu.data.1.AllItems.txt", sep=r"[ \t]+", engine="python")
# Get 'All items in U.S. city average, all urban consumers, seasonally adjusted'
overall = data[data["series_id"] == "CUSR0000SA0"]
# NB: pct_change() computes fractional change.
@mchapman87501
mchapman87501 / __main__.py
Created October 7, 2021 13:23
PySide6 vs. pyqt: Finding Qt Plugins
import os
from pathlib import Path
import sys
import sysconfig
from PySide6.QtCore import QCoreApplication
from PySide6.QtWidgets import QApplication
from .main_win import MainWin
def main() -> int:
@mchapman87501
mchapman87501 / install_pyside6_mac_m1.sh
Created October 1, 2021 18:47
Install PySide6 on macOS (Monterey) for M1 (Apple Silicon) Devices - h/t elliewhatever
#!/bin/bash
# Many thanks to
# https://gist.githubusercontent.com/elliewhatever/adbe3fba37d747fb8b04af8f835d46d2/raw/61e2bd530eb434f7ea2f595262e1922cdd057f7c/PySide6.sh
# Assumes brew and python are installed
brew install qt@6 llvm cmake ninja git
# Setup environment relative to current directory -
# this eases building in an existing Python venv.
mkdir -p ./.pyside6; cd ./.pyside6
@mchapman87501
mchapman87501 / Automator - Open in PDF Expert
Created April 11, 2020 16:47
Add an item to macOS "Print > PDF" popup menu, to save as PDF and open w. PDF Expert
#!/bin/zsh
# Open Automator
# File -> New
# Select "Print Plugin"
# In the resulting document:
# Drag Run Shell Script to the right-hand pane
# Set shell to /bin/zsh
# Paste in this script
filename=$(basename "$1")
@mchapman87501
mchapman87501 / fdio.py
Last active August 6, 2019 00:36
Transfer file descriptors across a socket - python, unix
#!/usr/bin/env python3
# I finally read the documentation for socket.sendmsg, and there it
# was: How to send a list of file descriptors over an AF_UNIX socket:
# https://docs.python.org/3/library/socket.html?highlight=sendmsg#socket.socket.sendmsg
# https://docs.python.org/3/library/socket.html?highlight=sendmsg#socket.socket.recvmsg
import array
import socket
import typing as tp
@mchapman87501
mchapman87501 / configure_with_openssl.zsh
Last active September 14, 2019 13:57
Configure Python 3.8.0b2 with home-brew tcl-tk and openssl
#!/bin/zsh
# Configure Python 3.8.0b2 with homebrew tcl-tk and openssl
# on macOS Catalina public beta with Xcode 11 beta 4
# Installs to ~/local.
set -e -u
brew update
brew install openssl tcl-tk