This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.
To capture the video (filesize: 19MB), using the free "QuickTime Player" application:
ls(all=T) | |
# character(0) | |
install.packages("crayon") | |
# trying URL 'http://cran.r-project.org/bin/macosx/mavericks/contrib/3.2/crayon_1.3.1.tgz' | |
# Content type 'application/x-gzip' length 604079 bytes (589 KB) | |
# ================================================== | |
# downloaded 589 KB | |
# | |
# | |
# The downloaded binary packages are in |
## Lightly edited for clarity | |
R version 3.2.2 (2015-08-14) -- "Fire Safety" | |
> install.packages("crayon") | |
trying URL 'http://cran.r-project.org/bin/macosx/mavericks/contrib/3.2/crayon_1.3.1.tgz' | |
Content type 'application/x-gzip' length 604079 bytes (589 KB) | |
================================================== | |
downloaded 589 KB |
f1 <- tempfile() | |
f2 <- tempfile() | |
cat("hello\n", file=f1) | |
cat("goodbye\n", file=f2) | |
con1 <- file(f1) | |
open(con1) | |
getAllConnections() | |
close(con1) |
# Tested on OS X and Ubuntu R 3.3.1, appears fixed in R-devel | |
# WARNING: you may have to kill your session if you run the code here | |
fun <- function() { | |
on.exit(cat('exited\n')) | |
stop('hello') | |
} | |
{ | |
browser() | |
# type `fun()` at Browser[1]> prompt to cause infinite loop |
list.A <- list( | |
list(a=1, b=2, c=matrix(1:9, 3)), | |
letters[1:16], | |
1:100, | |
head(warpbreaks, 3) | |
) | |
list.B <- list.A | |
list.B[[1]]$a <- list() | |
list.B[[1]]$c <- list.B[[1]]$c[-1, ] | |
list.B[[2]] <- LETTERS[1:16] |
reg <- "(A|B)*" # overflow | |
reg <- "([AB])*" # works | |
string <- paste0(rep("A", 1e4), collapse="") | |
grep(reg, string, perl=TRUE) |
Snippet used to compare valaddin
to vetr
performance. This is not actually
generated as part of vignettes because it will then require valaddin
as part
of the build package, which brings in unwanted dependencies (via suggests) that
make the build process slow on travis.
secant <- function(f, x, dx) (f(x + dx) - f(x)) / dx
secant_valaddin <- valaddin::firmly(secant, list(~x, ~dx) ~ is.numeric)
date.2 <- rep(Sys.Date(), 2) # length 2 date object | |
date.1 <- date.2[1] | |
valid_identifier_regex <- function() "^\\w+$" | |
date_between <- function(column_name, date_range) { | |
vetr( | |
character(1L) && grepl(valid_identifier_regex(), .), | |
(date.2 || date.1) && !anyNA(.) | |
) | |
TRUE |
blinkyverse_logo <- function() { | |
logo <- c(tidyverse::tidyverse_logo(unicode=FALSE)) | |
logoa <- gsub("*", "\u2b22", logo, fixed=TRUE) | |
logoa <- gsub("o", "\u2b21", logoa, fixed=TRUE) | |
logob <- gsub("o", "\u2b22", logo, fixed=TRUE) | |
logob <- gsub("*", "\u2b21", logob, fixed=TRUE) | |
logob <- gsub(".", "*", logob, fixed=TRUE) |