Skip to content

Instantly share code, notes, and snippets.

## Taskmaster - nudges you onto the most important task - by Peter Wildeford
## To install: (1) save this script as `~/bin/taskmaster.applescript`.
## (2) Use `crontab -e` and add `*/40 09-19 * * 0-5 osascript $HOME/bin/taskmaster.applescript` to your crontab
## (this will run the crontab every 40 minutes between 9am and 7pm on Mondays through Fridays - use https://crontab.guru/ to customize)
tell application "Finder"
activate
display alert "Taskmaster" message "Are you working on the most important task?" buttons ["No", "Yes"] default button 1
end tell
## Slack watcher - makes sure you only have Slack running if you should to avoid being distracted
## by Patrick Brinich-Langois, Ben Kuhn, and Peter Wildeford
## To install: (1) save this script as `~/bin/slack_watcher.applescript`.
## (2) Use `crontab -e` and add `*/22 * * * * osascript $HOME/bin/slack_watcher.applescript` to your crontab
## (this will run every 22 minutes while Slack is open - Slack will be closed if you press `No`)
tell application "System Events"
set activeApp to name of first process whose frontmost is true
end tell
@peterhurford
peterhurford / how_to_release_a_new_python_package.md
Last active October 19, 2023 01:09
How to release a new Python package

Nothing novel here, just want these instructions all in one place for my own use.

1.) Ensure everything is pushed to master and is working

2.) Ensure CHANGES.md is up to date with latest

3.) Ensure version in setup.py is incremented

4.) Tag the repo - e.g., git tag 0.2 && git push origin 0.2

@peterhurford
peterhurford / install_xelatex_on_mac.txt
Last active April 16, 2024 04:20
How to install latex and xelatex on Mac so that Jupyter "Download as PDF" will work
brew install pandoc
brew tap homebrew/cask
brew install --cask basictex
eval "$(/usr/libexec/path_helper)"
# Update $PATH to include `/usr/local/texlive/2022basic/bin/universal-darwin`
sudo tlmgr update --self
sudo tlmgr install texliveonfly
sudo tlmgr install xelatex
sudo tlmgr install adjustbox
sudo tlmgr install tcolorbox
@peterhurford
peterhurford / ballot_initiatives_model.R
Created December 17, 2018 02:37
Model predicting state-level ballot initiative outcomes
# Install and load libraries
if (!require("dplyr")) { install.packages("dplyr") }; library(dplyr)
if (!require("devtools")) { install.packages("devtools") }; library(devtools)
if (!require("readr")) { install.packages("readr") }; library(readr)
if (!require("recombinator")) { install_github("robertzk/recombinator") }; library(readr)
# Download data from https://docs.google.com/spreadsheets/d/1LzUHVgbyQddvESuW_WhJwNUn52023vYerlsho39em2I/edit#gid=0
states <- read_csv("~/Downloads/AR US States.csv")
@peterhurford
peterhurford / mint.R
Last active February 3, 2019 03:12
Look at Mint transaction data via R
## Load libraries
if (!require(readr)) { install.packages("readr") }; library(readr)
if (!require(magrittr)) { install.packages("magrittr") }; library(magrittr)
if (!require(dplyr)) { install.packages("dplyr") }; library(dplyr)
if (!require(tibbletime)) { install.packages("tibbletime") }; library(tibbletime)
if (!require(lubridate)) { install.packages("lubridate") }; library(lubridate)
if (!require(devtools)) { install.packages("devtools") }; library(devtools)
if (!require(shinyview)) { install_github("peterhurford/shinyview") }; library(shinyview)
## Load Mint transactions
@peterhurford
peterhurford / ec2_price_discovery.py
Last active August 24, 2018 18:46
Find the best deals in AWS spot instances across all availability zones and multiple instance types
# For every AWS availability zone and instance I care about, check the spot
# price for the last ninety days and generate stats about which spot instance
# gives the best deal.
import boto
import boto.ec2
from vowpal_platypus.utils import mean
REGIONS = {'us-east-1': ['us-east-1a', 'us-east-1b', 'us-east-1c', 'us-east-1e'],
@peterhurford
peterhurford / data_science_101.md
Created May 4, 2017 18:12
Initial stab at a Data Science 101 Curriculum
@peterhurford
peterhurford / meat_consumption_kg_meat_per_capita_per_country.csv
Created April 17, 2017 00:51
Meat consumption (kg meat consumed per capita) per country
COUNTRY BEEF PIG POULTRY SHEEP TOTAL
ARG 40.41400058 8.24187459 36.4689953 1.174247185 86.29911766
AUS 22.8010372 20.25072536 42.00750521 7.423454044 92.48272181
BGD 0.885267859 5.14E-04 1.223173534 1.163676301 3.272631248
BRA 24.15640871 11.20721696 39.36312514 0.393513724 75.12026453
BRICS 4.289081407 15.79587836 10.29847417 1.654767905 32.03820184
CAN 17.37132968 15.74658647 34.15846671 0.81704465 68.09342751
CHL 14.96778476 17.51448686 30.93243359 0.411750266 63.82645548
CHN 3.817396071 31.56769795 11.61724318 2.965417779 49.96775498
COL 12.10121226 5.084564383 26.43592901 0.202352547 43.8240582
@peterhurford
peterhurford / meat_consumption_by_country.md
Last active April 17, 2017 00:52
Meat consumption by country, kg per capita

Total kg per capita consumed of beef, veal, pork, poultry, and sheep meat by country in 2016, adapted from OECD Data on Meat Consumption. Per-animal breakdown is available as a CSV.

IND	2.944374911
BGD	3.358927799
ETH	4.449228451
NGA	6.061917778
TZA	6.986943733
MOZ	7.117845532
SSA	8.798326892