Skip to content

Instantly share code, notes, and snippets.

View nanxstats's full-sized avatar

Nan Xiao nanxstats

View GitHub Profile
@entaroadun
entaroadun / gist:1653794
Created January 21, 2012 20:10
Recommendation and Ratings Public Data Sets For Machine Learning

Movies Recommendation:

Music Recommendation:

## ruiling@ 07/08/2012
## input:
## x: sample data matrix, d×n
## d is the dimension of original sample
## n is the number of samples
## y: class label vector, n×1
## r: reduced dimension
## metric:type of metric in the embedding space
## 'weighted' ------ weighted eigenvectors
## 'orthonormalized' ------ orthonormalized
@zjf
zjf / c_which.R
Last active December 16, 2015 06:39
An equivalent which() function in Rcpp
cppFunction('
std::vector<int> c_which(NumericVector x, Function f, List args){
std::vector<int> ind = as< std::vector<int> >(f(x, args));
std::vector<int> out(ind);
std::vector<int>::iterator it;
int j = 0;
it = std::find(ind.begin(), ind.end(), 1);
while(it++ != ind.end()){
out[j++] = it - ind.begin();
it = std::find(it, ind.end(), 1);
@willurd
willurd / web-servers.md
Last active July 6, 2024 23:56
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@xiaodaigh
xiaodaigh / server.R
Last active August 18, 2022 17:45
Shiny: Disable Button
library(shiny)
disableActionButton <- function(id,session) {
session$sendCustomMessage(type="jsCode",
list(code= paste("$('#",id,"').prop('disabled',true)"
,sep="")))
}
shinyServer(function(input, output,session) {
@withr
withr / server.R
Last active June 12, 2024 23:52
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) {
@timelyportfolio
timelyportfolio / Readme.md
Created March 30, 2018 15:28
shiny datatables update streaming

Let's say you have streaming data, and you would like to update a DT::datatable in Shiny without completely re-rendering the table. Here is some code to illustrate how this might be accomplished. Hope it helps.

library(DT)
library(shiny)

ui <- tagList(
  tags$script(HTML(
"
Shiny.addCustomMessageHandler(