Skip to content

Instantly share code, notes, and snippets.

View gadenbuie's full-sized avatar

Garrick Aden-Buie gadenbuie

View GitHub Profile
@thomasp85
thomasp85 / styling.R
Created February 26, 2019 19:59
Single-quote styler
transformers <- styler::tidyverse_style()
transformers$token$fix_quotes <- function (pd_flat) {
str_const <- pd_flat$token == 'STR_CONST'
str_const_change <- grepl('^"(.*)"$', pd_flat$text[str_const])
raw_str <- sub('^"(.*)"$', '\\1', (pd_flat$text[str_const][str_const_change]))
raw_str <- gsub('(\\\\)?\'', '\\\\\'', raw_str)
raw_str <- gsub('\\\\"', '"', raw_str)
pd_flat$text[str_const][str_const_change] <- paste0('\'', raw_str, '\'')
pd_flat
}
@vi
vi / split_by_silence.sh
Last active February 23, 2024 13:18
Using FFmpeg to split multimedia file into parts based on audio volume level
#!/bin/bash
IN=$1
OUT=$2
true ${SD_PARAMS:="-55dB:d=0.3"};
true ${MIN_FRAGMENT_DURATION:="20"};
export MIN_FRAGMENT_DURATION
if [ -z "$OUT" ]; then
@rpodcast
rpodcast / README.md
Last active November 4, 2019 14:30
Shiny modules and custom SVG javascript

This app requires the shiny and xml2 packages. Run the gist interactively with the following:

shiny::runGist('6c33ee09a16d55569c562f7aa3951088')
@ovitente
ovitente / github actions debug
Created January 21, 2020 13:14
A way to debug Github Actions workflows
---
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners
name : debug
on :
push :
branches : [ "master" ]
read_csv("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv") %>%
gather(date, cases, 5:ncol(.)) %>%
mutate(date = as.Date(date, "%m/%d/%y")) %>%
group_by(country = `Country/Region`, date) %>%
summarise(cases = sum(cases)) %>%
filter(country != "Others" & country != "Mainland China") %>%
bind_rows(
tibble(country = "Republic of Korea", date = as.Date("2020-03-11"), cases = 7755)
) %>%
group_by(country) %>%
@MattNickodemus
MattNickodemus / 00_explanation.md
Last active October 29, 2020 14:29
Configure macOS Catalina to connect to Oracle DB using RStudio and odbc library

Setting up RStudio for Oracle pull using odbc on maxOS Catalina

  1. install unixodbc using homebrew

You can install homebrew here. Once that is done, run this in the terminal.

brew install unixodbc
  1. Download instant client from Oracle
@elliottmorris
elliottmorris / election_night_live_model.R
Last active January 29, 2024 18:56
A live election-night prediction model using The Economist's pre-election forecast
#' Description
#' This file runs a live election-night forecast based on The Economist's pre-election forecasting model
#' available at projects.economist.com/us-2020-forecast/president.
#' It is resampling model based on https://pkremp.github.io/update_prob.html.
#' This script does not input any real election results! You will have to enter your picks/constraints manually (scroll to the bottom of the script).
#'
#' Licence
#' This software is published by *[The Economist](https://www.economist.com)* under the [MIT licence](https://opensource.org/licenses/MIT). The data generated by *The Economist* are available under the [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/).
#' The licences include only the data and the software authored by *The Economist*, and do not cover any *Economist* content or third-party data or content made available using the software. More information about licensing, syndication and the copyright of *Economist* content can be fou
library(tidycensus)
library(ggiraph)
library(tidyverse)
library(patchwork)
vt_income <- get_acs(
geography = "county",
variables = "B19013_001",
state = "VT",
year = 2019,
@HenrikBengtsson
HenrikBengtsson / cran_submission_limits.R
Last active December 15, 2021 04:16
Figuring out how long too wait to avoid the limit of maximum 7 CRAN releases last 180 days
cran_days_since_release <- function(pkg, now = Sys.time()) {
db <- rbind(tools:::CRAN_archive_db()[[pkg]], tools:::CRAN_current_db()[pkg,])
now - sort(db$mtime, decreasing = TRUE)
}
# The CRAN rule is maximum 7 existing releases within the last 180 days
# https://github.com/wch/r-source/blob/tags/R-4-1-2/src/library/tools/R/QC.R#L7990-L8007
cran_wait_needed <- function(pkg, max = 7L, limit = 180, now = Sys.time()) {
since <- cran_days_since_release(pkg, now = now)
too_new <- since[since <= limit]
@andrewmoles2
andrewmoles2 / update.R
Last active October 5, 2023 12:08
Script to aid in installing packages after R update
# script to upgrade R and re-install all (or at least most) packages
# Pre-upgrade: save your packages as an rds file
my_pkg <- pak::pkg_list()
# if loaded from RStudio
#here::here("R", "update_packages", "my_packages.rds")
# if loaded from finder
saveRDS(object = my_pkg, file = "my_packages.rds")