Skip to content

Instantly share code, notes, and snippets.

@slopp
slopp / cookie
Created August 1, 2018 14:39
Example of adding a cookie to the cookie store during programmatic deployment
@slopp
slopp / apache-auth.conf
Created August 30, 2018 22:48
RSP Auth Proxy Sample (Does NOT Run Stand Alone, Just Pointer)
<VirtualHost *:80>
RewriteEngine on
<Proxy *>
Allow from localhost
</Proxy>
<Location />
## The following lines show an example using apache's simple auth module
@slopp
slopp / expose-curated.sh
Created September 24, 2018 17:49
Have RSPM track a list of packages in packages.txt
#!/bin/bash
RSPM_CLI=/opt/rstudio-pm/bin
PRODUCTION = $RSPM_CLI list repos | grep -c production
if [[ $PRODUCTION < 1 ]]; then
echo "Creating repository 'production'"
$RSPM_CLI create repo --name=production
fi
@slopp
slopp / check_users.Rmd
Last active October 31, 2018 17:43
RMD to email admin with daily user registrations
---
title: "Check Users"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
get_all_users <- function(){
connectServer <- Sys.getenv("RSTUDIO_CONNECT_SERVER")
apiKey <- Sys.getenv("RSTUDIO_CONNECT_API_KEY")
@slopp
slopp / get_publishers.R
Created October 31, 2018 19:56
Get RStudio Connect Publishers using Connect Server API
connectServer <- Sys.getenv("RSTUDIO_CONNECT_SERVER")
apiKey <- Sys.getenv("RSTUDIO_CONNECT_API_KEY")
# get user's list
authHeader <- httr::add_headers(Authorization = paste("Key", apiKey))
apiPrefix <- "__api__/v1/users?page_size=50&account_status=licensed&user_role=publisher"
resp <- httr::GET(
paste0(connectServer, apiPrefix),
authHeader
@slopp
slopp / health_check.R
Last active March 12, 2019 17:13
Test applications on RStudio Connect to see if they load successfully
# devtools::install_github("rstudio/connectapi")
library(connectapi)
library(purrr)
library(callr)
library(webshot)
library(glue)
#' Check Shiny App
#'
@slopp
slopp / check_license.R
Created April 17, 2019 15:03
How to figure out what packages are impacted by a license filter
library(stringr)
library(purrr)
library(dplyr)
library(devtool)
prohibit <- c(
"EPL-1.0",
"CDDL-1.1",
"MPL-1.1",
"CPL-1.0",
"OTN_Dev",
@slopp
slopp / 3d_ride.R
Created April 22, 2019 03:09
Code to make pretty bike ride plots with rayshader and rStrava
source("helpers.R")
plot_3d_route_area <- function(stream, zscale = 15){
# create bounding box for the ride
ui("1 of 5: Locating Route...")
bbox <- list(
p1 = list(long = min(stream$lng), lat = min(stream$lat)),
p2 = list(long = max(stream$lng), lat = max(stream$lat))
)
@slopp
slopp / Dockerfile
Created April 26, 2019 20:18
Dockerfile that creates a validated image based on a RStudio Package Manager repo
FROM ubuntu:bionic
ARG OS_IDENTIFIER=ubuntu-1804
ARG RSP_VERSION=1.2.1335-1
ARG RSP_PLATFORM=trusty
ARG R_VERSION=3.5.2
ARG REPO_BASE=http://demo.rstudiopm.com/validated
ARG REPO_PIN=1421
# Install the RSP bits for launcher
@slopp
slopp / add_bioc.R
Created September 12, 2019 22:47
Automatic workaround for adding BioCsoft packages to RSPM local source
# --- BioC RSPM Installer ----
# This R script is designed to be run by a user on the RStudio Package
# Manager server with access to the rspm command line utility
#
# The script loops through the R packages in the BioCsoft repository
# and adds them to a RSPM source called bioc_version
#
# To run this script, call Rscript add_bioc.R "3.9"
# Parse Inputs