I hereby claim:
- I am wch on github.
- I am winston (https://keybase.io/winston) on keybase.
- I have a public key ASBIcD-b7Mr5y30DdA4AfVp_I263JfDKgLboP2DYCHpfvwo
To claim this, I am signing this object:
# Test app for https://github.com/rstudio/shiny/pull/3666 | |
# pkgload::load_all() | |
library(promises) | |
library(httpuv) | |
library(htmltools) | |
library(shiny) | |
library(later) | |
options(shiny.minified = FALSE) |
# The code below demonstrates that in R, growing a vector in a loop can be fast, | |
# as long as there is only reference to the object. When there's only one | |
# reference to the vector, R grows it in place (in most cases). However, if | |
# there are other references to the object, R must make a copy the object | |
# instead of growing it in place, leading to slower performance. | |
# ========================================================================= | |
# Timing tests | |
# ========================================================================= |
This is a test, v2! |
# Web REPL/console | |
# Note: 127.0.0.1 allows connections only from localhost. To listen on external | |
# ports, use 0.0.0.0. | |
web_repl <- function(host = "127.0.0.1", port = 8080) { | |
library(httpuv) | |
app <- list( | |
call = function(req) { |
# @drob's version from https://twitter.com/drob/status/1501747414780239879 | |
pluck_recursive <- function(lst, name) { | |
if (is.list(lst)) { | |
if (!is.null(lst[[name]])) { | |
return(lst[[name]]) | |
} | |
return(unname(unlist(purrr::map(lst, pluck_recursive, name)))) | |
} | |
} |
library(inline) | |
get_mtime <- cfunction( | |
signature(filename = "character"), | |
includes = " | |
#include <time.h> | |
#include <sys/stat.h>", | |
body = ' | |
const char* path = CHAR(asChar(filename)); | |
struct stat attr; | |
stat(path, &attr); |
# Demonstration of using ContextVars instead of global variables. | |
# Set to True for global mode, False for ContextVar mode | |
global_mode = False | |
# With a global variable, the result is: 1 2 3 3 3 3 3 3 3 | |
# With a ContextVar, the result is: 1 2 3 1 2 3 1 2 3 | |
import asyncio | |
import contextvars |
# This code uses later's C API to schedule callbacks as quickly as possible, and | |
# it tests if the callbacks execute in the same order that they are scheduled. | |
# In Docker on Mac, they sometimes do not. | |
docker run --rm -ti rocker/shiny /bin/bash | |
R | |
install.packages(c('cpp11', 'later', 'brio', 'callr', 'cli', 'decor', 'desc', | |
'tibble', 'vctrs')) | |
library(cpp11) |
docker run --rm -ti --security-opt seccomp=unconfined wch1/r-debug | |
# ===================================================================== | |
# Setup | |
# ===================================================================== | |
RD -e 'install.packages(c("cpp11", "decor", "igraph"))' | |
RD -e 'remotes::install_github("r-lib/memtools", build_manual = FALSE, build_vignettes = FALSE)' | |
# ============================================================================== |
I hereby claim:
To claim this, I am signing this object: