Skip to content

Instantly share code, notes, and snippets.

@timelyportfolio
Created November 12, 2012 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timelyportfolio/4059340 to your computer and use it in GitHub Desktop.
Save timelyportfolio/4059340 to your computer and use it in GitHub Desktop.
runGist amended for Windows
#all code credit goes to https://github.com/rstudio/shiny/
#this is a simple two line change to deal with Windows tar difficulties
#thanks to http://www.worthinstalling.com/2006/06/command-line-compression-for-windows.html for the good explanation
#to use this install bsdtar in Windows
#in R require(Shiny) and then run this to override runGist
runGist <- function (gist, port = 8100L, launch.browser = getOption("shiny.launch.browser",
interactive()))
{
gistUrl <- if (is.numeric(gist) || grepl("^[0-9a-f]+$", gist)) {
sprintf("https://gist.github.com/gists/%s/download",
gist)
}
else if (grepl("^https://gist.github.com/([0-9a-f]+)$", gist)) {
paste(sub("https://gist.github.com/", "https://gist.github.com/gists/",
gist), "/download", sep = "")
}
else {
stop("Unrecognized gist identifier format")
}
filePath <- tempfile("shinygist", fileext = ".tar.gz")
if (download.file(gistUrl, filePath, mode = "wb", quiet = TRUE) !=
0)
stop("Failed to download URL ", gistUrl)
on.exit(unlink(filePath))
dirname <- untar(filePath, list = TRUE, tar="bsdtar.exe")[1]
untar(filePath, exdir = dirname(filePath),tar="bsdtar.exe")
appdir <- file.path(dirname(filePath), dirname)
on.exit(unlink(appdir, recursive = TRUE))
shiny::runApp(appdir, port = port, launch.browser = launch.browser)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment