Skip to content

Instantly share code, notes, and snippets.

View withr's full-sized avatar

Huidong Tian withr

View GitHub Profile
@withr
withr / app.js
Created February 8, 2016 09:51
NationalTest5
// 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");
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 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);
},
@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 / 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 / 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 / server.R
Last active August 29, 2015 13:57
shinyServer(function(input, output) {
observe({
print(input$daterange)
})
})
@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 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 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)