Skip to content

Instantly share code, notes, and snippets.

View daattali's full-sized avatar

Dean Attali daattali

View GitHub Profile
@hadley
hadley / shiny-oauth.r
Last active April 26, 2024 05:41
Sketch of shiny + oauth
library(shiny)
library(httr)
# OAuth setup --------------------------------------------------------
# Most OAuth applications require that you redirect to a fixed and known
# set of URLs. Many only allow you to redirect to a single URL: if this
# is the case for, you'll need to create an app for testing with a localhost
# url, and an app for your deployed app.
@jimhester
jimhester / enum.R
Created December 4, 2017 18:19
Simple C style enum in R.
enum <- function(...) {
nms <- eval(substitute(alist(...)))
x <- as.list(setNames(seq_along(nms), nms))
f <- tempfile()
attach(x, name = f)
# Cleanup the enum if when the parent frame exists
# unless we are in the global environment.
if (!identical(parent.frame(), globalenv())) {
withr::defer(detach(name = f), parent.frame())
}
@jcheng5
jcheng5 / README.md
Last active June 26, 2020 01:08
Using a more recent version of jQuery with Shiny

To opt into a more recent version of jQuery, you can add an htmlDependency object pointing to your desired version, somewhere (anywhere) in your UI:

htmltools::htmlDependency("jquery", "3.3.1",
  src = c(href = "https://code.jquery.com/"),
  script = "jquery-3.3.1.min.js")

This example will serve jQuery 3.3.1 from the jQuery CDN. If your app needs to work with clients that won't be able to connect to the wider internet, you'll need to download the jquery-3.3.1.min.js file, put it in an app subdirectory (say, jquery), and point to the directory using the src argument.