Skip to content

Instantly share code, notes, and snippets.

View gadenbuie's full-sized avatar

Garrick Aden-Buie gadenbuie

View GitHub Profile
library(purrr)
l1 <- list(a = list(a1 = 1:10))
l2 <- list(a = list(a2 = 10:20))
list_merge(l1, l2)
#' But both `l1` and `l2` are named... so arguments should be named?
list_merge(x = l1, y = l2)
#' Oh, l2 is implicitly unnamed because it's in dots
list_merge(l1, y = l2)
#' But what I *really* wanted was this
list_modify(l1, rlang::splice(l2))
---
output: github_document
---
# magick ![](http://www.textfiles.com/underconstruction/HeHeartlandPark2601underconstructionbar9.gif)
##### *Advanced Image-Processing in R*
[![Build Status](https://travis-ci.org/ropensci/magick.svg?branch=master)](https://travis-ci.org/ropensci/magick)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/ropensci/magick?branch=master&svg=true)](https://ci.appveyor.com/project/jeroen/magick)
@gadenbuie
gadenbuie / post-commit
Last active March 7, 2018 20:15 — forked from rmflight/post-commit
useful commit hooks for R package dev
#!/usr/bin/env Rscript
# License: CC0 (just be nice and point others to where you got this)
# Author: Robert M Flight <[email protected]>, github.com/rmflight
#
# This is a post-commit hook that after a successful commit subsequently increments the package version in DESCRIPTION
# and commits that. Analogous to the pre-commit at https://gist.github.com/rmflight/8863882, but useful if you only have
# good reasons for not doing it on the pre-commit.
#
# To install it, simply copy this into the ".git/hooks/post-commit" file of your git repo, change /path/2/Rscript, and make
@gadenbuie
gadenbuie / render_toc.R
Last active April 24, 2025 09:54
Generate Manual Table of Contents in (R)Markdown Documents
#' Render Table of Contents
#'
#' A simple function to extract headers from an RMarkdown or Markdown document
#' and build a table of contents. Returns a markdown list with links to the
#' headers using
#' [pandoc header identifiers](http://pandoc.org/MANUAL.html#header-identifiers).
#'
#' WARNING: This function only works with hash-tag headers.
#'
#' Because this function returns only the markdown list, the header for the
---
title: regextest notes
output:
html_document:
css: inst/style.css
keep_md: yes
---
```{r setup, include=FALSE}
library(purrr)
@gadenbuie
gadenbuie / gifify.sh
Last active September 18, 2019 17:25
Convert screencast mov to gif
#!/bin/sh
palette="/tmp/palette.png"
filters="fps=6,scale=720:-1:flags=bicubic"
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2
@gadenbuie
gadenbuie / directoryIndex.html
Last active April 23, 2018 01:57
My Shiny directory index template
<!DOCTYPE html>
<html>
<head>
<title>{{title}}</title>
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro' rel='stylesheet' type='text/css'>
<!-- <link rel="stylesheet" href="https://unpkg.com/[email protected]/build/base-min.css"> -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
body {
@gadenbuie
gadenbuie / basic_miniUI_gadget.R
Created April 24, 2018 13:14
A basic miniUI Shiny gadget
#' Basic miniUI Gadget Function
#'
#' Single view with button row along the bottom
basic_miniUI_gadget <- function() {
require(shiny)
require(miniUI)
ui <- miniPage(
gadgetTitleBar("Shiny gadget example"),
miniContentPanel(
#' Create a public Github gist and send to carbon.now.sh, then browse to both.
#'
#' Create a public Github gist and browse to it, then open the gist in
#' [carbon.now.sh](https://carbon.now.sh), for easily Tweeting a saucy code pic.
#' The gist will contain the active text selection or the active RStudio tab.
#' Gist file is named: `RStudio_<project>_<filename or file_id>`. `file_id` is
#' a unique id for untitled files. It does not relate to the untitled number.
#' @return nothing.
#' @export
gistfoc <- function() gistfo_base(mode = "carbon")
@gadenbuie
gadenbuie / find-libs.R
Last active September 8, 2018 22:39 — forked from hrbrmstr/find-libs.R
find libraries used in your R scripts or Rmd documents
find_used_libraries <- function(path = getwd(), include_rmd = FALSE, by_file = FALSE) {
library(tidyverse)
if (!requireNamespace('sessioninfo', quietly = TRUE)) {
install.packages("sessioninfo")
library(sessioninfo)
}
library_pattern <- paste(
"(?:library|require)\\((.+?)\\)", # pkgs via library, require, etc.
"requireNamespace\\(['\"](.+?)['\"].+?\\)",
"([[:alnum:]_]+):{2,3}[[:alnum:]_]+", # pkgs via pkgname::function()