Skip to content

Instantly share code, notes, and snippets.

View leonawicz's full-sized avatar

Matt Leonawicz leonawicz

  • Denver, Colorado, USA
View GitHub Profile
@leonawicz
leonawicz / app.R
Last active March 14, 2021 06:27
Use custom local image files as icons in a Shiny Dashboard value box
#
# This Shiny web application demonstrates the use of custom image files
# in place of icons for value boxes in Shiny Dashboard by overriding two
# functions:
#
# 'icon' from the shiny package and 'valueBox' from the shinydashboard package.
#
# Each function adds minimal, specific additional handling of image files.
# Note: A custom css file must also be included so that value boxes can
# display the icons. For that reason, do not expect images in place of icons to
@leonawicz
leonawicz / bst.R
Last active September 7, 2020 02:14
Basic Bootrap Tour R wrapper example
# Bootstrap tour step
.bsTourStep <- function(i, id, title, content, pos = "right", tab = NULL){
id <- paste0("#", id)
x <- paste0(" {\n element: \"", id,
"\",\n title: \"", title,
"\",\n content: \"", content,
"\",\n placement: \"", pos, "\"")
if(i==1 && !is.null(tab)){
x <- paste0(x, ",\n onShow: function (tour) { $(\"", tab, "\").tab('show');}\n }")
} else {
@leonawicz
leonawicz / server.R
Created February 1, 2017 23:08
Divs issue with dynamic server-side rintrojs and shiny dashboard for some widgets?
library(shiny)
library(rintrojs)
shinyServer(function(input, output, session) {
steps <- reactive(data.frame(
element=c("#plot1", "#select1", "#slider1"),
intro=c("This is a plot.", "The selectInput.", "Thw sliderInput."),
position=c("bottom", "bottom", "right")
))
observeEvent(input$help, { introjs(session, options=list(steps=steps())) })
@leonawicz
leonawicz / shiny_app_styles.css
Created June 29, 2017 15:39
Common styling for Shiny apps
.img-local {
}
.small-box .img-local {
position: absolute;
top: auto;
bottom: 5px;
right: 5px;
z-index: 0;
font-size: 70px;
@leonawicz
leonawicz / tabr-example-complete-arrangement.R
Created December 4, 2018 22:01
Example guitar arrangement using R code
title <- "Devil in me"
composer <- "Words and music by Gin Wigmore"
performer <- "Gin Wigmore"
album <- "Gravel and Wine"
subtitle <- paste("From the album", album, "by", performer)
arranger <- "Arranged by Matthew Leonawicz"
copyright <- "2011 Island Records"
tagline <- paste(arranger, Sys.Date())
# CHORDS
@leonawicz
leonawicz / double_animate.R
Last active February 28, 2019 18:17
memery + rayshader
library(rayshader)
library(magick)
img <- image_read("meme_plot.gif")
n <- 36
phivec = 50 + 40 * 1/(1 + exp(seq(-2, 10, length.out = n) * 2))
thetavec = -44 + 45 * 1/(1 + exp(seq(-2, 10, length.out = n) * 2))
zoomvec = 0.6 + 0.25 * 1/(1 + exp(seq(-2, 10, length.out = n) * 2))
focusvec = 0.55 + -0.2 * 1/(1 + exp(seq(-4, 8, length.out = n) / 2))
@leonawicz
leonawicz / tuning-example.Rmd
Last active December 14, 2019 01:26
tabr example: Hard to Handle intro - open G tuning (requires tabr >= v0.4.1)
---
title: "Change tuning when rendering tabs"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Hard to handle - intro