Skip to content

Instantly share code, notes, and snippets.

@noamross
noamross / ropensci_editor_workloads.R
Last active April 1, 2018 17:34
Checking editor workloads for rOpenSci onboarding
library(tidyverse)
library(gh)
library(lubridate)
issues <- gh("/repos/ropensci/onboarding/issues?state=all&labels=package", .limit=1000)
edits = map_df(issues,
~data_frame(url = .$html_url,
editor = .$assignee$login %||% NA_character_,
opened = as.Date(.$created_at))) %>%
#!/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")
library(desc)
library(httr)
library(purrr)
library(stringi)
library(methods)
library(dplyr)
library(tidyr)
pkgs <- rownames(available.packages())
if(!dir.exists("DESCRIPTIONS")) dir.create("DESCRIPTIONS")
# Noam's take on Bob's lobseter plot
library(stringi)
library(pdftools)
library(hrbrthemes) #devtools::install_github("hrbrmstr/hrbrthemes"); hrbrthemes::import_roboto_condensed()
library(tidyverse)
# A different file provided by the state includes fishing effort
lobster_tbl <- "https://www.maine.gov/dmr/commercial-fishing/landings/documents/lobster.table.pdf"
lobster_tbl_fil <- basename(lobster_tbl)
# Oh man, I'm sorry, my GITHUB_PAT didn't have 'gist' scope! Carry on.
library(googledrive)
gdoc_to_md <- function(file, path=NULL, markdown="markdown") {
td <- tempdir()
gf <- googledrive::drive_download(
file, path = td,
type = "application/epub+zip", overwrite = TRUE
)
if (is.null(path)) {
path <- file.path(getwd(), paste0(gf$name, ".md"))
library(googledrive)
gdoc_to_md <- function(file, path=NULL, markdown="markdown") {
td <- tempdir()
gf <- googledrive::drive_download(
file, path = td,
type = "application/epub+zip", overwrite = TRUE
)
if (is.null(path)) {
path <- file.path(getwd(), paste0(gf$name, ".md"))
@noamross
noamross / gh_file.R
Last active December 3, 2020 09:25
Function to download a file from github via API, including large files and private repos
# TODO (maybe)
# - Vectorize on URLs
# - Allow for downloading whole directory contents if path is a directory
# - Make a recursive = TRUE argument for this case
# - Error messages/input checking
#' Gets a file from a github repo, using the Data API blob endpoint
#'
#' This avoids the 1MB limit of the content API and uses [gh::gh] to deal with
#' authorization and such. See https://developer.github.com/v3/git/blobs/
@noamross
noamross / mkrproj.sh
Last active January 17, 2018 13:33 — forked from bearloga/mkrproj.sh
A bash shell script that can be used to turn the current directory into an RStudio project, opening the project in RStudio after creating it.
#!/bin/bash
# Usage: mkproj [projectname]
# projectname defaults to name of current directory
template="Version: 1.0
RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Yes
@noamross
noamross / ecohealth-alliance-disease-ecologist-2017.md
Created December 6, 2017 22:37
JOB ADVERTISMENT: Disease Ecologist

JOB ADVERTISMENT: Disease Ecologist

https://www.ecohealthalliance.org/career/disease-ecologist

EcoHealth Alliance seeks a Disease Ecologist with strong quantitative skills for a six-month, full-time position. The Disease Ecologist will work with our team of scientists and staff on a research project modeling the risk of import and spread of foot-and-mouth disease in the cattle and swine sectors in the USA. Responsibilities of the Disease Ecologist include developing and performing simulations, performing statistical analyses, assembling and curating data sets, performing literature reviews and writing reports. The candidate must have strong epidemiological and computational skills, including experience with stochastic simulation, spatial analyses, and network models. The candidate must have strong writing skills and the ability to work independently.

PRIMARY RESPONSIBILITIES