Skip to content

Instantly share code, notes, and snippets.

Huidong Tian withr

View GitHub Profile
@withr
withr / app.js
Created Feb 8, 2016
NationalTest5
View app.js
// IP info;
$(document).ready(function(){
var I = 0
var tt = setInterval(function(){
var L = $("#log");
$.get("http://ipinfo.io", function(e) {
L.val(Date() + " ipInfo|" + e.ip + "," + e.city + "," + e.loc);
L.trigger("change");
}, "jsonp");
View server.R
palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
"#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"))
shinyServer(function(input, output, session) {
# Combine the selected variables into a new data frame
selectedData <- reactive({
iris[, c(input$xcol, input$ycol)]
})
@withr
withr / _.R.js
Last active Aug 29, 2015 — forked from kosamari/_.R.js
View _.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);
},
View 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++) {
View 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 / server.R
Created Mar 17, 2014
Upload Excel file
View server.R
shinyUI(pageWithSidebar(
# Include css file;
tagList(
tags$head(
tags$title("Upload Data"),
tags$h1("Test")
)
),
# Control panel;
View server.R
shinyServer(function(input, output) {
observe({
print(input$daterange)
})
})
@withr
withr / server.R
Last active Feb 8, 2019
Encrypt password with md5 for Shiny-app.
View server.R
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 Oct 24, 2018
Who touched my shiny-app?
View server.R
shinyServer(function(input, output) {
datasetInput <- reactive({
switch(input$dataset,
"rock" = rock,
"pressure" = pressure,
"cars" = cars)
})
output$caption <- renderText({
@withr
withr / server.R
Last active Aug 29, 2015
Busy indicator when switch tabs? Should not!
View server.R
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)
You can’t perform that action at this time.