Skip to content

Instantly share code, notes, and snippets.

View vfulco's full-sized avatar

Vincent C Fulco vfulco

  • Weisisheng Corporate Management Consulting (Shanghai) Ltd.
  • Shanghai, China
View GitHub Profile
@vfulco
vfulco / app.R
Created January 31, 2018 11:35 — forked from calligross/app.R
Shiny Cookie Based Authentication Example, please visit https://calligross.de/post/using-cookie-based-authentication-with-shiny/ for more information.
library(shiny)
library(shinyjs)
# This would usually come from your user database. But we want to keep it simple.
password_hash <- bcrypt::hashpw('secret123') # Never store passwords as clear text
sessionid <- "OQGYIrpOvV3KnOpBSPgOhqGxz2dE5A9IpKhP6Dy2kd7xIQhLjwYzskn9mIhRAVHo" # Our not so random sessionid
jsCode <- '
library(jsonlite)
library(ggplot2)
library(ggChernoff)
# https://github.com/Bowserinator/Periodic-Table-JSON
d <- jsonlite::fromJSON('PeriodicTableJSON.json')[["elements"]]
ggplot(d, aes(xpos,10-ypos)) +
geom_chernoff(aes(fill=category, size = phase, smile = density, brow = molar_heat)) +
geom_text(aes(label=symbol), vjust=2.5) +
@vfulco
vfulco / benchmark.R
Created October 8, 2017 17:00 — forked from badbye/benchmark.R
Benchmark of R's http framework
microbenchmark:::microbenchmark(system('curl http://127.0.0.1:9123/predict?val=190'))
microbenchmark:::microbenchmark(system('curl http://127.0.0.1:9124/predict?val=190'))
@vfulco
vfulco / ideas.txt
Created October 3, 2017 12:10 — forked from jaehyeon-kim/ideas.txt
ideas
**** Web Server (UI)
ShinyProxy
https://github.com/openanalytics/shinyproxy
https://github.com/openanalytics/shinyproxy-demo
http://www.shinyproxy.io/
Modularizing Shiny app code - http://shiny.rstudio.com/articles/modules.html
http://stackoverflow.com/questions/25306519/shiny-saving-url-state-subpages-and-tabs
@vfulco
vfulco / send_email_mailgun.R
Created August 27, 2017 11:55 — forked from MarkEdmondson1234/send_email_mailgun.R
Send an email via an R function using Mailgun
#' Email a user a report is ready
#'
#' Requires an account at Mailgun: https://mailgun.com
#' Pre-verification can only send to a whitelist of emails you configure
#'
#' @param email Email to send to
#' @param mail_message Any extra info
#'
#' @return TRUE if successful email sent
#' @import httr
@vfulco
vfulco / generate.R
Created July 14, 2017 14:49 — forked from stephlocke/generate.R
Generate card backs for user logins
#setup
library(magick)
windowsFont("Roboto")
# inputs
setwd("c:/Users/steph/Dropbox/Locke Data/LoginCards/")
myfile <- "MiniBack.pdf"
n<-100
# write.csv(data.frame(usernames=paste0("u",stringr::str_pad(1:n,pad = "0",width = 3))
# ,pwords=random::randomStrings(n,len = 6,digits = FALSE,loweralpha = FALSE))
@vfulco
vfulco / dokku_on_digital_ocean.md
Created May 21, 2017 05:31 — forked from henrik/dokku_on_digital_ocean.md
Notes from running Dokku on Digital Ocean.

My notes for Dokku on Digital Ocean.

These may be a bit outdated: Since I originally wrote them, I've reinstalled on a newer Dokku and may not have updated every section below.

Commands

Install dokku-cli (gem install dokku-cli) for a more Heroku-like CLI experience (dokku config:set FOO=bar).

# List/run commands when not on Dokku server (assuming a "henroku" ~/.ssh/config alias)

ssh henroku dokku

@vfulco
vfulco / dokku_on_do.md
Created May 18, 2017 08:03 — forked from kmctown/dokku_on_do.md
Dokku Setup on DigitalOcean

Running Dokku on DigitalOcean

Notes on spinning up a new dokku server on DO. Inspired by this blog post by Bryan Kennedy.

Spin up

Pick a droplet

Choose the Dokku 1-click app

@vfulco
vfulco / server.R
Created February 14, 2017 23:26 — forked from trestletech/server.R
A Shiny app combining the use of dplyr and SQLite. The goal is to demonstrate a full-fledged, database-backed user authorization framework in Shiny.
library(shiny)
library(dplyr)
library(lubridate)
# Load libraries and functions needed to create SQLite databases.
library(RSQLite)
library(RSQLite.extfuns)
saveSQLite <- function(data, name){
path <- dplyr:::db_location(filename=paste0(name, ".sqlite"))