Skip to content

Instantly share code, notes, and snippets.

@peterhurford
peterhurford / install_xelatex_on_mac.txt
Created Aug 21, 2020
How to install latex and xelatex on Mac so that Jupyter "Download as PDF" will work
View install_xelatex_on_mac.txt
brew install pandoc
brew tap homebrew/cask
brew cask install basictex
eval "$(/usr/libexec/path_helper)"
# Update $PATH to include `/usr/local/texlive/2020basic/bin/x86_64-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 Dec 17, 2018
Model predicting state-level ballot initiative outcomes
View ballot_initiatives_model.R
# 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 Feb 3, 2019
Look at Mint transaction data via R
View mint.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 Aug 24, 2018
Find the best deals in AWS spot instances across all availability zones and multiple instance types
View ec2_price_discovery.py
# 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
Initial stab at a Data Science 101 Curriculum
View data_science_101.md
@peterhurford
peterhurford / meat_consumption_kg_meat_per_capita_per_country.csv
Created Apr 17, 2017
Meat consumption (kg meat consumed per capita) per country
View meat_consumption_kg_meat_per_capita_per_country.csv
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 Apr 17, 2017
Meat consumption by country, kg per capita
View meat_consumption_by_country.md

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
@peterhurford
peterhurford / r-packages-abridged.md
Last active Nov 7, 2018
"R Packages" by Hadley Wickham, Abridged
View r-packages-abridged.md

R Packages, Abridged

Consider completing "Advanced R, Abridged" and "Git 101 Exercises" first.

"Advanced R" by Hadley Wickham is widely considered the best resource to improve your knowledge at building an R package. This guide is designed to give you the most essential parts of R Packages so that you can get going right away. It still will take a long time, but not as long.

--

  1. Read the following chapters of "R Packages" by Hadley Wickham:
View advanced-r-abridged.md

Advanced R, Abridged

"Advanced R" by Hadley Wickham is widely considered the best resource to improve your knowledge at R. However, going through it and answering every exercise takes a long time. This guide is designed to give you the most essential parts of Advanced R so that you can get going right away. It still will take a long time, but not as long.

--

1.) Quickly skim these chapters (without doing the exercises) to make sure you're familiar with the concepts:

@peterhurford
peterhurford / git-101-exercises.md
Last active Jun 11, 2020
Git 101, with Exercises
View git-101-exercises.md

Git 101, with Exercises

Git is the key tool we use to allow multiple people to work on the same code base. Git takes care of merging everyone's contributions smoothly. Hence, learning how to use Git is critical to contributing to open source.

Exercises

Exercise 1: Go through the Try Git Guide

Exercise 2: Learn How to file a github issue.

You can’t perform that action at this time.