Skip to content

Instantly share code, notes, and snippets.

View jhollist's full-sized avatar

Jeffrey W Hollister jhollist

View GitHub Profile

Playing with adding + operator for easily joining geojson objects together into a single valid geojson object. This is relatively easy with lists, but not so easy with json unless you speak json.

Get lawn package too for viewing data

devtools::install_github("ropensci/geojsonio")
@dill
dill / irltoots.R
Last active January 5, 2018 10:45
Make a grid of twitter folks I've met IRL
# you need my horse library from here: https://github.com/dill/horse
library(horse)
library(magrittr)
library(knitr)
setup_twitter_oauth("you auth stuff",
"goes here",
"you can't use mine",
"it's mine")
@jhollist
jhollist / get_nars.R
Last active January 26, 2017 18:12
R script to scrape US EPA NARS data and metadata
#Script to scrape NARS website
library(rvest)
library(dplyr)
nars <- read_html("https://www.epa.gov/national-aquatic-resource-surveys/data-national-aquatic-resource-surveys")
links <- nars %>%
html_nodes(".file-link, a") %>%
html_attr("href") %>%
tbl_df() %>%
filter(grepl("files",value)) %>%
@Myfanwy
Myfanwy / timer.R
Created July 28, 2017 04:31
Timer function for R
# Depends on the `beepr` package by @rasmusab: https://cran.r-project.org/web/packages/beepr/README.html
# Code greatly improved by flodel on Stack Exchange Code Review (thanks flodel)
# Planned improvements/expansions: new end-of-timer sounds, add functionality for starting a separate R session so that it doesn't bogart the current one.
timer <- function(interval, units = c("secs", "mins", "hours", "days", "weeks")) {
units <- match.arg(units)
num_sec <- interval * switch(units, secs = 1, mins = 60, hours = 3600,
days = 86400, weeks = 604800)
Sys.sleep(num_sec)
if (require(beepr)) beep(2) else message("TIMER DONE YO!")
@fawda123
fawda123 / gist:5ecb73e1304e7faee83eb05b922937e7
Created August 31, 2017 20:09
save git log to csv with header
echo sha, contributor, date, message > log.csv
git log --date=local --pretty=format:'%h, %an, %ad, "%s"' >> log.csv
#!/usr/bin/env Rscript
json_in <- file('stdin', 'r')
lat_newp <- '{"t":"RawBlock","c":["latex","\\\\newpage"]}'
doc_newp <- '{"t":"RawBlock","c":["openxml","<w:p><w:r><w:br w:type=\\"page\\"/></w:r></w:p>"]}'
ast <- paste(readLines(json_in, warn=FALSE), collapse="\n")
@benmarwick
benmarwick / super-and-sub-script-labels.R
Last active July 26, 2025 09:02
ggplot axis labels with superscript and subscript
library(tidyverse)
# using expression() for the text formatting:
ggplot(mtcars,
aes(disp,
mpg)) +
geom_point() +
# ~ for spaces, and * for no-space between (unquoted) expressions
ylab(expression(Anthropogenic~SO[4]^{"2-"}~(ngm^-3))) +
xlab(expression(italic(delta)^13*C[ap]*"‰")) +