This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(openxlsx) | |
font_name <- "Comic Sans MS" | |
sheet_name <- "font_test" | |
font_null <- createStyle(fontName = font_name) | |
font_black <- createStyle(fontName = font_name, fontColour = "black") | |
font_red <- createStyle(fontName = font_name, fontColour = "red") | |
row_seq <- 1:nrow(beaver1) | |
wb_openxlsx <- createWorkbook() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You can combine: | |
# * {cli} for link-clicking in the console: | |
# https://www.rostrum.blog/posts/2023-09-17-choosethis/ | |
# * the ability to 'monetise' your R packages: | |
# https://www.rostrum.blog/posts/2023-08-01-monetize/ | |
add_one <- function(x) { | |
result <- x + 1 | |
cli::cli_text( | |
"The answer, ", result, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
png( | |
"~/Desktop/qr_test.png", | |
width = 5, | |
height = 5, | |
units = "cm", | |
res = 1200 | |
) | |
qrcode::qr_code("https://www.matt-dray.com") |> plot() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Regarding this toot: https://fosstodon.org/@coolbutuseless/111134523140682110 | |
# Referring to this guidance: https://cran.r-project.org/web/packages/policies.html | |
# Using this deep-fry tech: https://www.rostrum.blog/posts/2021-11-07-deepfry/ | |
library(magick) | |
library(spongebob) | |
fry <- function( | |
img_path, emoji_path, | |
text_top, text_bottom, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Freeing Brian Bilston's spreadsheet-based 'Cells' poem | |
# https://x.com/brian_bilston/status/1704061266979959099?s=46&t=QpOVBfS2sVIbcjn3ZLif3g | |
# Assuming the poem is saved to the file cells.xlsx | |
cells <- tidyxl::xlsx_cells("cells.xlsx", include_blank_cells = FALSE) | |
txt <- cells$character | |
txt_len <- length(txt) | |
author <- paste0("-", txt[txt_len]) | |
txt <- txt[-txt_len] | |
lines <- split(txt, ceiling(seq_along(txt) / max(cells$col))) |> append(author) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
redirect_to <- paste0("/", list.dirs("posts", recursive = FALSE)) | |
date_rx <- "\\d{4}-\\d{2}-\\d{2}" | |
date_portion <- regexpr(date_rx, redirect_to) |> | |
regmatches(redirect_to, m = _) |> | |
gsub("-", "/", x = _) | |
name_portion <- gsub(paste0("posts/", date_rx, "-"), "", redirect_to) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x <- data.frame( | |
col_a = c("A", "B", "A", "C", "A", "D", "B", "C"), | |
col_b = c(1, 2, 1, 3, 9, 4, 2, 9) | |
) | |
x | |
# col_a col_b | |
# 1 A 1 | |
# 2 B 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
posts <- | |
list.files("posts", pattern = ".qmd", recursive = TRUE, full.names = TRUE) | |
get_categories <- function(post_path, ignore_rx = "resources") { | |
post_lines <- readLines(post_path, warn = FALSE) | |
cats_start <- which(post_lines == "categories:") + 1 | |
cats_end <- which(post_lines == "---")[2] - 1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x <- readLines("~/Desktop/leaflet-map.txt") | |
popup_html <- stringr::str_split_1(x, "\",\"") | |
lmb_simple <- tibble::tibble( | |
status_id = stringr::str_extract(popup_html, "\\d{19}"), | |
lat = stringr::str_extract(popup_html, "(?<=📍 )5\\d{1}\\.\\d{0,4}(?=, )"), | |
lon = stringr::str_extract(popup_html, "(?<=\\d, )(-)?\\d\\.\\d{0,4}(?=<br>📮)"), | |
osm_url = glue::glue("https://www.openstreetmap.org/#map=17/{lat}/{lon}/"), | |
media_url = stringr::str_extract(popup_html, "(?<=img src=\\')http://pbs\\.twimg\\.com/media/.*\\.jpg(?=\\' width)") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
paths <- list.dirs("posts", recursive = FALSE) | |
for (i in paths) { | |
from_dir <- i | |
date_rx <- "\\d{4}-\\d{2}-\\d{2}" | |
dates <- regexpr(date_rx, basename(i)) |> | |
regmatches(basename(i), m = _) |> |