Skip to content

Instantly share code, notes, and snippets.

View MattSandy's full-sized avatar
💭
Hungry

Matt Sandy MattSandy

💭
Hungry
View GitHub Profile
@MattSandy
MattSandy / cases_to_deaths.R
Created September 20, 2021 18:41
Plots and gives some info on correlation
library(tidyverse)
library(lubridate)
library(zoo)
library(scales)
# Read Data ---------------------------------------------------------------
confirmed <- read_csv("https://github.com/nytimes/covid-19-data/raw/master/us-states.csv")
@MattSandy
MattSandy / companies.R
Last active August 18, 2021 23:48
Inc. 5000 Fastest Growing Companies
library(tidyverse)
library(jsonlite)
df <- "https://api.inc.com/rest/i5list/2021" %>%
fromJSON() %>%
.$companies %>%
bind_rows() %>%
unnest(article) %>%
select(-editorsPick) %>%
write_csv("inc.csv")
@MattSandy
MattSandy / registered-voters.R
Last active November 7, 2020 03:41
Voter Shift
name,registered_voters_2020,registered_voters_2016
Aitkin,"10,840","10,090"
Anoka,"228,495","206,600"
Becker,"21,396","18,829"
Beltrami,"27,518","24,213"
Benton,"24,688","22,106"
Big Stone,"3,212","3,090"
Blue Earth,"39,978","36,184"
Brown,"16,209","15,052"
Carlton,"22,253","20,424"
@MattSandy
MattSandy / extract_tables_from_pdf.R
Last active October 29, 2020 02:00
Extracts Tables from PDF and puts them into a dataframe
library(tidyverse)
library(pdftools)
week <- 42
mn_counties <- c("Aitkin","Anoka","Becker","Beltrami","Benton","Big Stone","Blue Earth","Brown","Carlton","Carver","Cass","Chippewa","Chisago","Clay","Clearwater","Cook","Cottonwood","Crow Wing","Dakota","Dodge","Douglas","Faribault","Fillmore","Freeborn","Goodhue","Grant","Hennepin","Houston","Hubbard","Isanti","Itasca","Jackson","Kanabec","Kandiyohi","Kittson","Koochiching","Lac qui Parle","Lake","Lake of the Woods","Le Sueur","Lincoln","Lyon","McLeod","Mahnomen","Marshall","Martin","Meeker","Mille Lacs","Morrison","Mower","Murray","Nicollet","Nobles","Norman","Olmsted","Otter Tail","Pennington","Pine","Pipestone","Polk","Pope","Ramsey","Red Lake","Redwood","Renville","Rice","Rock","Roseau","Saint Louis","Scott","Sherburne","Sibley","Stearns","Steele","Stevens","Swift","Todd","Traverse","Wabasha","Wadena","Waseca","Washington","Watonwan","Wilkin","Winona","Wright","Yellow Medicine","Unknown/missing")
location <- paste0("https://www.health.state.mn.us/diseases/
@MattSandy
MattSandy / burritos.js
Created September 28, 2020 01:56
Checks Tacocat for when burritos are available for order.
// Twilio Credentials
const accountSid = "accountSid";
const authToken = "authToken";
//require the Twilio module and create a REST client
const client = require("twilio")(accountSid, authToken);
//END Twilio
const fetch = require("node-fetch");
setInterval(() => {
check_if_available();
@MattSandy
MattSandy / Rplot.png
Last active September 23, 2020 01:04
Vaporwave R Plot
Rplot.png
@MattSandy
MattSandy / quickstart.php
Last active May 26, 2020 17:57
Object Oriented Database Connection Quickstart
<?php
define('DB_NAME', 'zip');
/** MySQL database username */
define('DB_USER', '*****');
/** MySQL database password */
define('DB_PASSWORD', '*****');
/** MySQL hostname */
@MattSandy
MattSandy / server.R
Created September 28, 2015 01:46
Creates a websocket based JSON server
#Connect to this using websockets on port 9454
#Send in the format of {"data":[1,2,3]}
#The ppp returns the standard deviation of the sent array
library(jsonlite)
library(httpuv)
#server
app <- list(
onWSOpen = function(ws) {
ws$onMessage(function(binary, message) {
write(message, file = "log.txt",append = TRUE, sep = "\n")
@MattSandy
MattSandy / census.R
Last active April 8, 2020 16:45
NYT Covid-19 Data Merged with Census
library(tidycensus)
library(tidyverse)
library(viridisLite)
library(gganimate)
library(patchwork)
us_county_population <- get_estimates(geography = "county",
product = "population",
shift_geo = TRUE, geometry = TRUE,
year = 2018) %>%
@MattSandy
MattSandy / South_Korea_COVID-19.R
Created March 17, 2020 01:37
Plot confirmed COVID-19 cases in SK
library(tidyverse)
library(lubridate)
library(ggthemes)
library(forecast)
library(xts)
library(timetk)
future <- 7
confirmed <- read_csv("https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv")
South_Korea <- list()