Skip to content

Instantly share code, notes, and snippets.

@dtenenba
Created July 19, 2013 21:28
Show Gist options
  • Save dtenenba/6042479 to your computer and use it in GitHub Desktop.
Save dtenenba/6042479 to your computer and use it in GitHub Desktop.
library(httr)
myRunApp <- function(...)
{
try(hostname <- suppressWarnings(system2(c("hostname", "-d"),
stdout=TRUE, stderr=NULL)),
silent=TRUE)
if (exists("hostname") && length(hostname) &&
grepl("ec2\\.internal", hostname))
{
dots <- list(...)
dots[["launch.browser"]] <- FALSE
if (is.null(dots[['port']])) dots[['port']] <- 8103L
library(httr)
public.dns <-
httr::content(GET("http://169.254.169.254/latest/meta-data/public-hostname"))
url <- paste0("http://", public.dns, ":", dots[["port"]])
#cat("Press Reload in the browser window that appears.\n")
cat("If you don't see a new window, ")
cat("try disabling your popup blocker and try again.\n")
cat("Press ESCAPE in this window when done.\n")
browseURL(url)
do.call(runApp, dots)
} else {
runApp(...)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment