Skip to content

Instantly share code, notes, and snippets.


Dean Attali daattali

View GitHub Profile
jcheng5 /
Last active Jun 26, 2020
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 = ""),
  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.

jimhester / enum.R
Created Dec 4, 2017
Simple C style enum in R.
View enum.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())
hadley / shiny-oauth.r
Last active Mar 24, 2022
Sketch of shiny + oauth
View shiny-oauth.r
# 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.
calligross / app.R
Last active Apr 7, 2022
Shiny Cookie Based Authentication Example, please visit for more information.
View app.R
if (!dir.exists('www/')) {
url = '',
destfile = 'www/js.cookie.js'
jimhester / 0.9.3.png
Last active Jul 11, 2018
Run R code with different versions of package dependencies, this will work in the same session as long as you don't run into issues unloading the namespaces
daattali / rselenium-taxonomer-1-upload.R
Last active Jun 24, 2019
Use RSelenium to automatically upload many FASTQ files, submit each to "full analysis" when it's ready, and download the analyzed file on
View rselenium-taxonomer-1-upload.R
# This script uploads all the FAST files to the taxonomer server (only one file can be uploaded at a time)
# Assumes that you have RSelenium package installed and that you've got a simple selenium example to work
if (FALSE) {
fastq_files <- c(
list.files(# WHERE ARE THE FILES?, pattern = "fastq.gz$", full.names = TRUE)
login_password <- "" # what is my password???
View parse_extract_html_table_w_content_preserved.R
#compare with
url <- ""
get_html_table <- function(url){
xx <- xml2::read_html(url)
tr_to_nms <- function(tbl){
jimhester / forks_n_commits.R
Created Apr 21, 2016
Programmatically determine forks of a repo with at least n commits. Does not try to disambiguate repeated force pushes.
View forks_n_commits.R
# Q on @GitHub: does anyone now how to easily (ie automatically) list all forks
# of a repository that have more than N commits in the fork?
library(gh) # devtools::install_github("gaborcsardi/gh")
forks_n_commits <- function(owner, repo, n = 1) {
events <- gh("GET /networks/:owner/:repo/events", owner = owner, repo = repo, .limit = Inf)
fork_pushes <- Filter(function(x) x$type == "PushEvent" && x$repo$name != paste0(owner, "/", repo),
daattali / gmailr-text.R
Last active Mar 30, 2018
Send a text message via email from R
View gmailr-text.R
ui <- fluidPage(
textInput("subj", "Subject", "Schedule change"),
textInput("text", "Message"),
actionButton("btn", "Send")
server <- function(input, output, session) {
lgatto / colour-picker.R
Last active Nov 7, 2015
A simple interface to select colours
View colour-picker.R
colour_picker <- function() {
n <- length(colours())
i <- ceiling(sqrt(n))
m <- matrix(c(1:n, rep(NA, i^2 - n)),
ncol = i, nrow = i)
## plotting
image(m, col = colours(),
xaxt = "n", yaxt = "n")
k <- seq(0, 1, length.out = i)
kk <- expand.grid(k, k)