Skip to content

Instantly share code, notes, and snippets.

View withr's full-sized avatar

Huidong Tian withr

View GitHub Profile
@withr
withr / server.R
Created February 4, 2014 07:32
"Calculation In Process..." busy indictor
shinyServer(function(input, output) {
output$obs <- renderUI({
sliderInput("obs", "Number of observations:",
min = 10000, max = 90000,
value = 50000, step = 10000)
})
output$distPlot <- renderPlot({
if (!is.null(input$obs)) {
dist <- NULL
for (i in 1:input$obs) {
@withr
withr / A1.txt
Last active August 29, 2015 13:56
Highcharts exporting problem
"Year" "MeldingsNr" "HF0105" "HF0208" "HF0305" "HF0502" "HF0601" "HF0707" "HF0806" "HF1005" "HF1101" "HF1107" "HF1305" "HF1406" "HF1502" "HF1504" "HF1608" "HF1701" "HF1702" "HF1801" "HF1903"
"1" "2011" 100 58 NA NA NA 19 NA NA NA NA NA NA NA NA NA NA NA NA NA NA
"2" "2011" 200 48 NA NA NA 16 NA NA NA NA NA NA NA NA NA NA NA NA NA NA
"3" "2011" 250 2 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
"4" "2011" 400 3 NA NA NA 6 NA NA NA NA NA NA NA NA NA NA NA NA NA NA
"5" "2011" 401 2 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
"6" "2011" 602 1 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
"7" "2011" 700 137 NA NA NA 1 NA NA NA NA NA NA NA NA NA NA NA NA NA NA
"8" "2011" 750 2 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
"9" "2012" 100 178 NA 40 NA 637 303 NA 98 NA 135 22 NA 39 1 56 NA NA 34 19
@withr
withr / server.R
Last active August 29, 2015 13:56
Busy indicator when switch tabs? Should not!
shinyServer(function(input, output) {
output$hist1 <- renderPlot({
n <- (input$obs)
dist <- NULL
for (i in 1:n) {
dist <- c(dist, rnorm(1))
}
hist(dist,main = paste("hist1", n), breaks = 100)
@withr
withr / server.R
Last active October 24, 2018 14:05
Who touched my shiny-app?
shinyServer(function(input, output) {
datasetInput <- reactive({
switch(input$dataset,
"rock" = rock,
"pressure" = pressure,
"cars" = cars)
})
output$caption <- renderText({
@withr
withr / server.R
Last active April 3, 2024 19:55
Encrypt password with md5 for Shiny-app.
library(shiny)
library(datasets)
Logged = FALSE;
PASSWORD <- data.frame(Brukernavn = "withr", Passord = "25d55ad283aa400af464c76d713c07ad")
# Define server logic required to summarize and view the selected dataset
shinyServer(function(input, output) {
source("www/Login.R", local = TRUE)
observe({
if (USER$Logged == TRUE) {
@withr
withr / server.R
Last active August 29, 2015 13:57
shinyServer(function(input, output) {
observe({
print(input$daterange)
})
})
@withr
withr / server.R
Created March 17, 2014 14:08
Upload Excel file
shinyUI(pageWithSidebar(
# Include css file;
tagList(
tags$head(
tags$title("Upload Data"),
tags$h1("Test")
)
),
# Control panel;
@withr
withr / PiCameraStream
Last active August 29, 2015 14:15 — forked from nioto/PiCameraStream
#!/usr/bin/python
'''
A Simple mjpg stream http server for the Raspberry Pi Camera
inspired by https://gist.github.com/n3wtron/4624820
'''
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
import io
import time
import picamera
@withr
withr / uustats.js
Last active August 29, 2015 14:16 — forked from olivoil/uustats.js
(function(uustats){
uustats.sdev = function(series) {
return Math.sqrt(uustats.variance(series));
};
uustats.variance = function(series) {
var t = 0, squares = 0, len = series.length;
for (var i=0; i<len; i++) {
@withr
withr / _.R.js
Last active August 29, 2015 14:16 — forked from kosamari/_.R.js
_.mixin({
sum : function(data){
return _.reduce(data, function(memo, num){ return memo + num; }, 0);
},
mean : function(data){
return this.sum(data)/data.length
},
median : function(data){
return this.percentile(data,50);
},