Skip to content

Instantly share code, notes, and snippets.

@HughParsonage
Created December 26, 2023 05:17
Show Gist options
  • Save HughParsonage/fd620a31489123ad85a7b0b48286069f to your computer and use it in GitHub Desktop.
Save HughParsonage/fd620a31489123ad85a7b0b48286069f to your computer and use it in GitHub Desktop.
Snow?
snow <- function() {
w <- getOption("width")
flakes <- c(rep(" ", 10), "*", " ", " ", "*", "❄︎", "❅", "❆")
falls <-
vapply(1:50, function(x) {
paste0(sample(flakes, size = w - 10, replace = TRUE), collapse = "")
}, FUN.VALUE = "")
panes <- lapply(1:50, function(x) {
paste0(c(rev(falls[seq_len(x)]), rep(strrep(" ", w), 50 - x)),
sep = "\n", collapse = "")
})
repeat({
for (i in seq_along(panes)) {
Sys.sleep(1)
cat(panes[[i]])
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment