Skip to content

Instantly share code, notes, and snippets.

View kissmygritts's full-sized avatar
🚀

Mitchell Gritts kissmygritts

🚀
  • Reno, NV
View GitHub Profile
library(httr)
usgsapi <- function () {
API_URL <- 'https://m2m.cr.usgs.gov/api/api/json/stable/'
ENDPOINTS <- list(
login = paste0(API_URL, 'login'),
permissions = paste0(API_URL, 'permissions'),
scene_search = paste0(API_URL, 'scene-search')
)
TOKEN <- NULL
@kissmygritts
kissmygritts / hello-world.R
Created October 15, 2020 23:41
simple R script
print('hello world')
telemetry_dir <- here::here('data', 'telemetry')
# simplest?
files <- dir(telemetry_dir)
grep_files <- files[!(is.na(stringr::str_extract(files, 'GSM\\d*.csv')))]
df <- tibble::tibble()
for(i in seq_along(grep_files)) {
d <- readr::read_csv(file.path(telemetry_dir, grep_files[i]))
@kissmygritts
kissmygritts / regex.sql
Created March 29, 2019 16:13
regex to select formatted lab ids
select distinct
specimenid
from health.labs
where specimenid !~ '([[:alnum:]]+)(_|-)(\d+)(_|-)(\d+)';
@kissmygritts
kissmygritts / survey_com.sql
Last active December 29, 2018 01:10
survey classification queries
-- male classification
SELECT
tbl_survey_comp.event_key AS event_id,
tbl_survey_comp.SPECIES,
"alive" AS life_status,
"adult" AS age_class,
"male" AS sex,
tbl_survey_comp.Male AS n,
[YRLG_M]+[1pt]+[2pt]+[3pt]+[4pt]+[5pts+]+[6pts+]+[2_3yrs]+[4_5yrs]+[6yrs+] AS total_m,
"{" &
@kissmygritts
kissmygritts / module2_6.r
Created November 10, 2018 20:15
install and download data
install.packages(c('dplyr', 'spData', 'sf', 'raster', 'rgdal', 'rgeos', 'rcartocolor', 'magrittr', 'leaflet'))
file_name <- 'http://naes.unr.edu/shoemaker/teaching/R-Bootcamp/data.zip'
download.file(file_name, destfile = 'data.zip')
unzip(zipfile = 'data.zip', exdir = '.')
import { makeExecutableSchema } from 'graphql-tools';
// data
const posts = [
{ id: 1, authorId: 1, title: 'Introduction to GraphQL', votes: 2 },
{ id: 2, authorId: 2, title: 'Welcome to Apollo', votes: 3 },
{ id: 3, authorId: 2, title: 'Advanced GraphQL', votes: 1 },
{ id: 4, authorId: 3, title: 'Launchpad is Cool', votes: 7 },
{ id: 5, authorId: 3, title: 'Apollo-Client, the Artemis to My Apollo Server', votes: 7 },
{ id: 6, authorId: 1, title: 'Illuminate Errors with Apollo 2.0', votes: 7 },
@kissmygritts
kissmygritts / setup.md
Created May 16, 2018 19:37
Windows bash setup

Linux Subsystem

Setup and install the Linux subsystem

Hyper

This command line looks much nicer than the default powershell.

hyper i hyper-dracula to install a new plugin. Don't run from bash.

const getName = (person) => person.name
const uppercase = (string) => string.toUpperCase()
const getCharacters = (start, end) => (string) => string.substring(start, end)
const reverse = (string) => string.split('').reverse().join('')
const pipe = (...fns) => x => fns.reduce((v, f) => f(v), x)
const newString = pipe(
getName,
uppercase,
@kissmygritts
kissmygritts / muld915-spring2014.R
Created January 31, 2018 22:43
Code to reproduce figures for TWS presentation
dat <- readr::read_csv('sandbox/test-muld.csv')
df <- dat %>%
filter(ndowid == 915)
mig_df <- df %>%
filter(timestamp >= mdy('1/1/2014') &
timestamp <= mdy('6/30/2014'))
mig_df <- mig_df %>%