Skip to content

Instantly share code, notes, and snippets.

View jennybc's full-sized avatar

Jennifer (Jenny) Bryan jennybc

View GitHub Profile
@jennybc
jennybc / github-pat-checksum.R
Created January 20, 2024 16:20
Noodling with the GitHub PAT checksum
pat <- gitcreds::gitcreds_get()
cksum <- digest::digest(
substr(pat$password, start = 5, stop = nchar(pat$password) - 6),
algo = "crc32", serialize = FALSE
)
# https://stackoverflow.com/q/5478508
toBase <- function(num, base=62) {
# bv <- c(seq(0,9),letters,LETTERS)
# GitHub seems to do UPPERCASE then lowercase
@jennybc
jennybc / miles.md
Last active February 25, 2021 07:05
A rowwise summary problem where we don't want to use `rowwise()`
library(tidyverse)

(df <- tibble(
  id = 1:3,
  wut = letters[3:1],
  x1 = 1:3,
  x2 = 4:6,
  x3 = 7:9
))
@jennybc
jennybc / locale-demo-output.md
Last active February 14, 2021 00:45
Localization demo

I execute:

reprex({
  # inheriting everything from local system
  # for Jenny, this means English
  "a" / 2
  1:3 == c(1:2, 5)
  format(as.Date(c("2019-01-01", "2019-02-01")), "%d %B %Y")
})

══ Reverse dependency check ══════════════════════════════════════ portalr 0.3.6 ══

Status: BROKEN

── Newly failing

x checking tests ... ERROR

── Before ───────────────────────────────────────────────────────────────────────── 0 errors ✓ | 0 warnings ✓ | 0 notes ✓

@jennybc
jennybc / 2020-03-29_sane-legend.R
Created March 30, 2020 05:21
Make the legend order = data order, with forcats::fct_reorder2()
library(tidyverse)
library(patchwork)
dat_wide <- tibble(
x = 1:3,
top = c(4.5, 4, 5.5),
middle = c(4, 4.75, 5),
bottom = c(3.5, 3.75, 4.5)
)
Exerting my will over the gist name
@jennybc
jennybc / vv_transformer.R
Last active August 9, 2019 18:32
A glue transformer inspired by the "variables & values" f-string syntax in Python 3.8
library(glue)
vv_transformer <- function(text, envir) {
regex <- "=$"
if (!grepl(regex, text)) {
return(identity_transformer(text, envir))
}
text <- sub(regex, "", text)
res <- identity_transformer(text, envir)
n <- length(res)
@jennybc
jennybc / get-function-signatures_reprex.R
Last active December 26, 2019 18:15
List all function signatures in a package
library(tidyverse)
## attach the package whose function signatures you want to examine
pkg <- "usethis"
library(pkg, character.only = TRUE)
x <- lsf.str(pos = paste0("package:", pkg))
## inspired by examining print.ls_str and head.function
get_signatures <- function(x) {
x %>%
curl 'https://sheets.googleapis.com/v4/spreadsheets/1eP_0mb67k0MD9BBEZ5gv7jsyFzcTvMbrr3uGTG1GXZk?includeGridData=true&ranges=Sheet1!A1%3AG6&key=AIzaSyDXicV6oK4vR948PUAvlyr7QhkNwCoQ0cA' -H 'Accept: application/json' --compressed > spreadsheets_get_3.json
curl 'https://sheets.googleapis.com/v4/spreadsheets/1eP_0mb67k0MD9BBEZ5gv7jsyFzcTvMbrr3uGTG1GXZk/values/Sheet1!A1%3AG6?key=AIzaSyDXicV6oK4vR948PUAvlyr7QhkNwCoQ0cA' -H 'Accept: application/json' --compressed > spreadsheets_values_get_3.json
curl 'https://sheets.googleapis.com/v4/spreadsheets/132Ij_8ggTKVLnLqCOM3ima6mV9F8rmY7HEcR-5hjWoQ?includeGridData=true&ranges=Sheet1!A1%3AF6&key=AIzaSyDXicV6oK4vR948PUAvlyr7QhkNwCoQ0cA' -H 'Accept: application/json' --compressed > spreadsheets_get_2.json
curl 'https://sheets.googleapis.com/v4/spreadsheets/132Ij_8ggTKVLnLqCOM3ima6mV9F8rmY7HEcR-5hjWoQ/values/Sheet1!A1%3AF6?key=AIzaSyDXicV6oK4vR948PUAvlyr7QhkNwCoQ0cA' -H 'Accept: application/json' --compressed > spreadsheets_values_get.json