Skip to content

Instantly share code, notes, and snippets.

@gsee
gsee / server.R
Last active October 13, 2015 02:08
shiny TrueFX quotes
# Based on (more) code by Joe Cheng:
# https://groups.google.com/d/msg/shiny-discuss/NE-LqDAVqQQ/kNdrtC4WxGAJ
# https://gist.github.com/4044364
#-------------------------------------------------------------------------------
if (!require(TFX) && !require(TrueFX)) {
stop("TFX must be installed; run 'install.packages(\"TFX\")'.\n")
}
shinyServer(function(input, output, session) {
output$currentTime <- renderText({
# Forces invalidation in 1000 milliseconds
@gsee
gsee / server.R
Last active January 6, 2020 13:09
simple streaming shiny plot
set.seed(42)
dat <- rnorm(1)
shinyServer(function(input, output) {
fetchData <- reactive(function() {
invalidateLater(1000)
qt <- rnorm(1)
dat <<- c(dat, qt)
dat
})
output$plot_dat <- reactivePlot(function() { plot(fetchData(), type='l') })
@gsee
gsee / CoinbaseExchangeEnterOrder.R
Last active September 18, 2019 20:30
authenticate and place an order on Coinbase Exchange in R
library(RCurl) # for base64Decode(), base64Encode(), getURLContent(), and getCurlHandle()
library(digest) # for hmac()
library(RJSONIO) # for toJSON() and fromJSON()
api.key <- "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
secret <- "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
passphrase <- "your passphrase"
api.url <- "https://api.gdax.com"
req.url <- "/orders"