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 / wordCountRmdFile.R
Created February 2, 2018 11:46 — forked from m-Py/wordCountRmdFile.R
Count words in Rmd file using the package wordcountaddin
# This function reads a Rmd file and returns the word count
# It uses the wordcountaddin and koRpus packages
text_stats_file <- function(rmdFile) {
rmd <- file(rmdFile, "rt")
text <- readLines(rmd)
conText <- ""
for (i in text) {
conText <- paste(conText, i)
}
close(rmd)
@vfulco
vfulco / render_and_send.R
Created February 2, 2018 09:40
render rmarkdown script
filename_script <- "analyze_nfl_picks_v02"
filename_ext <- ".docx"
filename_output <- paste0("output/",
# filename_script)
filename_script,
filename_ext)
#'
#'
#'
@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 / AUC.R
Created January 24, 2014 14:25 — forked from cjbayesian/AUC.R
###################################################
##
## Functions for calculating AUC and plotting ROC
## Corey Chivers, 2013
## corey.chivers@mail.mcgill.ca
##
###################################################
## Descrete integration for AUC calc
@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