Skip to content

Instantly share code, notes, and snippets.

@slopp
slopp / database.Rmd
Created January 24, 2017 00:43
Python + SQL in RStudio Notebooks
---
title: "dplyr Database Example"
output: github_document
---
```{r}
library(DBI)
library(RSQLite)
# Can be any DBI compliant database connection
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
snippet gg
ggplot(${1:data}, aes(${2:aes})) +
geom_${3:geom}()
snippet shiny
library(shiny)
ui <- fluidPage(
${1:ui}
)
---
output:
html_document:
code_folding: hide
toc: yes
toc_float: yes
params:
symbol: GOOG
days:
label: "Number of Previous Days"
library(shiny)
ui <- fluidPage(
sliderInput('x', "x", min = 0, max = 10, value = 0),
actionButton('go', 'Go')
)
server <- function(input, output, session) {
observeEvent(input$go, {
validate(
need(input$x > 5, message = "I'll never be seen!")
@slopp
slopp / app.R
Last active June 1, 2017 20:32
Pachyderm Shiny App
# App requires a pachyderm pipeline with
# input repo "images"
# output repo "edges"
# The app assumes that pachyderm is being run locally with minikube.
# See: http://pachyderm.readthedocs.io/en/latest/getting_started/beginner_tutorial.html
# Setup -------------------------------------------------------------------
library(shiny)
source("flickr_api.R") # file for querying flickr
@slopp
slopp / tfestimators_test.R
Created August 7, 2017 14:55
Initial Test of tfestimators
Sys.setenv(PATH = '/Users/Sean/.virtualenvs/r-tensorflow/bin:$PATH')
library(tfestimators)
library(readr)
library(stringr)
library(purrr)
col_names = c(
"age", "workclass", "fnlwgt", "education", "education_num",
"marital_status", "occupation", "relationship", "race", "gender",
"capital_gain", "capital_loss", "hours_per_week", "native_country",
@slopp
slopp / app.R
Created August 9, 2017 15:04
Screen Height Demo
library(shiny)
ui <- fluidPage(
textOutput("height"),
tags$script('
$(window).bind("resize", function () {
Shiny.onInputChange("height", $(document).height());
});'
@slopp
slopp / code.js
Created August 9, 2017 21:57
Googlesheets Client Code For Plumber Demo
/**
* Call plumber API with id to return profile
*
* @param {number} id The customer id
* @param {string} key API Key
* @customfunction
*/
function getProfileFromPlumber(id, key) {
@slopp
slopp / load-test.R
Created August 22, 2017 01:39
shinyloadtest v0.2 proto
library(parallel)
library(processx)
# config
t.test <- 120
n.processes <- 12
t.update <- 10
# storage