Skip to content

Instantly share code, notes, and snippets.

View gadenbuie's full-sized avatar

Garrick Aden-Buie gadenbuie

View GitHub Profile
@gadenbuie
gadenbuie / cities.json
Created April 16, 2024 12:45
World-wide cities with population 15k+
This file has been truncated, but you can view the full file.
[
{
"name": "les Escaldes",
"state": "Escaldes-Engordany",
"country": "Andorra",
"latitude": 42.5073,
"longitude": 1.5341,
"timezone": "Europe/Andorra"
},
{
@gadenbuie
gadenbuie / utpr.R
Last active March 14, 2024 14:30
usethis pr command line helper
#! /usr/bin/env Rscript
if (!requireNamespace("rlang", quietly = TRUE)) {
stop("`utpr` requires `{usethis}`: install.packages('usethis')")
}
rlang::check_installed(c("usethis", "cli", "docopt"))
'
A command-line wrapper for `pr_*` helper functions from {usethis}.
@gadenbuie
gadenbuie / bslib-function-prefixes.md
Last active July 13, 2023 14:16
bslib function prefixes
library(tidyverse)

bsf <- pkgnet::FunctionReporter$new()
bsf$set_package("bslib")
bsf$calculate_default_measures()
bslib_fns <-
@gadenbuie
gadenbuie / 01-hello-dashboards.R
Last active March 16, 2024 05:49
Example apps using bslib v0.5.0
# https://shiny.posit.co/blog/posts/bslib-dashboards/#hello-dashboards
library(shiny)
library(bslib)
library(ggplot2)
# Setup -------------------------------------------------------------------
data(penguins, package = "palmerpenguins")
Installing package into ‘/Users/garrick/Library/R/arm64/4.3/library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/httpuv_1.6.10.tar.gz'
Content type 'application/x-gzip' length 1875497 bytes (1.8 MB)
==================================================
downloaded 1.8 MB
* installing *source* package ‘httpuv’ ...
** package ‘httpuv’ successfully unpacked and MD5 sums checked
** using staged installation
---
title: Reading a YAML chunk
output: github_document
---
Here's a simple YAML chunk (with the label `config`):
```{yaml config}
default:
user: "garrick"
@gadenbuie
gadenbuie / pkgdown-watch.R
Last active May 11, 2023 03:40
Watch a package and rebuild pkgdown docs when they change
#!/usr/bin/env -S Rscript --vanilla
rlang::check_installed(c("docopt", "pkgdown", "servr", "fs", "pkgload"))
'usage:
pkgdown-watch [--port=<port> --rebuild --no-sound]
pkgdown-watch -h | --help
options:
--port=<port> Port to use for the server [default: 4323]
snps <-
list(r = "~/.config/rstudio/snippets/r.snippets") %>%
purrr::map(readLines, warn = FALSE) %>%
purrr::map(paste, collapse = "\n") %>%
purrr::map(trimws) %>%
purrr::map(strsplit, split = "(^|\n)snippet ") %>%
purrr::map_depth(2, ~ .x[.x != ""]) %>%
purrr::map_depth(2, ~ {
nm <- gsub("^([^\n\t ]+).*", "\\1", .x)
names(.x) <- nm