Skip to content

Instantly share code, notes, and snippets.

@slopp
slopp / avit
Created August 24, 2017 19:08
ZSH
PROMPT='
$(_user_host)${_current_dir} $(git_prompt_info)
%{$fg[$CARETCOLOR]%}->%{$resetcolor%} '
PROMPT2='%{$fg[$CARETCOLOR]%}◀%{$reset_color%} '
RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
local _current_dir="%{$fg_bold[darkgrey]%}%3~%{$reset_color%} "
local _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
@slopp
slopp / handout.Rmd
Created October 27, 2017 12:51
LaTex + RMD
---
title: \textbf{USING RSTUDIO WITH TERADATA \\ \large RStudio makes it easy to access and analyze your data with R}
geometry: margin=0.6in
output:
pdf_document:
fig_caption: false
pandoc_args: [
"-V", "classoption=twocolumn"
]
---
@slopp
slopp / instructions.md
Last active December 14, 2017 21:03
proxyrec failure repro

See https://rstudio.github.io/shinyloadtest for instructions.

recording.txt is a test file for the Geyser app located at http://banff.rstudio.com/helloload.

The test takes about 43 minutes to run. The test is really simple (the slider moves every 5 seconds). For a shorter test, just truncate recording.txt after any of the WS_RECV lines (or right before any of the WS_SEND lines) keeping at least the first 26 lines.

The app is on a big 16 core box, utilization scheduler:

@slopp
slopp / day1.go
Last active December 3, 2017 23:51
Advent Of Code
package main
import (
"fmt"
"strconv"
"math"
)
func main() {
input := "82393664534558127269567731851345949183464112984439374267255354443912631439984677323484553559335534893149949618483958211881768917194863586442785221532542143371745897577136952213876624822596324216865897532635478541525297429431713851114182622686636455576111717876454343589988671142631967544367982918125749696621943583162156551966798989872583663962668164582171486144314189342767238471673276588484477243337479818595574131111636589965983363423793887818136731721863553966735736429575474482959584296277352458422542796946746761164159183487676982971924813661314735129853488556314411433621196167439291218173577385163429822745415788524176915681178761189734996533147421722346117689664324297539722785969655449299693723542327254934834952855943221452155165697113685997223285412626234938125442459734887444773654572226195787127593575676418437899416742798381171667547625785855646475567747872514658874714785737529367571157574713247172793377351257136846738615196656859
@slopp
slopp / analyse.R
Last active January 12, 2018 17:34
shinyloadtest analyze functions part 2
createLogDf <- function(logsDir, testId) {
files <- list.files(logsDir)
log <- list()
for (i in seq_along(files)) {
fname <- file.path(logsDir, files[i])
f <- readr::read_csv(fname, skip = 1)
info <- readr::read_lines(fname, n_max = 1)
sess <- as.numeric(gsub('# --sessions (\\d+) .*', '\\1', info))
@slopp
slopp / recursive_deps.R
Created May 18, 2018 20:50
Get recursive package dependencies and versions
# --- SAMPLE CMD INVOCATION ---
# Rscript recursive_deps.R ggplot2 tidyverse broomn
# ---- HARD CODED INPUTS ---
repo <- 'https://cran.rstudio.com'
dep_types <- c("Depends", "Imports", "LinkingTo")
# -- IMPLEMENTATION ---
args = commandArgs(TRUE)
message(
@slopp
slopp / stock-dashboard.Rmd
Last active July 18, 2019 19:41
Transformation from Static to Shiny Dashboard
---
title: "Stock Analysis"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
@slopp
slopp / 03_shiny_dashboard.Rmd
Created July 10, 2018 23:04
Answer to RStudio Portfolio Advanced Question
---
title: "Stock Analysis"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
@slopp
slopp / plumber.R
Last active July 11, 2018 22:52
More complicated plumber API example showing how to parse JSON inputs
library(plumber)
library(dplyr)
library(tidyquant)
library(jsonlite)
get_volatility <- function(ticker = 'GOOG') {
price <- tq_get(ticker, from = "2018-01-01")
volatility <- price %>%
select(date, adjusted) %>%
mutate(returns = (log(adjusted) - log(lag(adjusted)))) %>%
@slopp
slopp / email-demo.Rmd
Created July 16, 2018 21:16
Send dynamic email from RSC
---
output: html_document
params:
symbol: TSLA
threshold: 10
force: True
---
# Report for `r params$symbol` on `r Sys.Date()`