#mlpack on Windows
mlpack, while not designed with Windows as a specific target, can still be built and run on Windows with some configuration. This document details the steps necessary to get MLPACK compiled using MinGW64.
#Prerequisites
// | |
// Based on code sent by Kevin Ushey | |
// to Rcpp-devel on Tue, 8 Jul 2014 | |
// | |
#ifndef LIST_BUILDER_H | |
#define LIST_BUILDER_H | |
#include <Rcpp.h> | |
using namespace Rcpp; |
require(reshape2) | |
require(rgl) | |
plot_rgl_model <- function(fdata){ | |
fdata <- fdata[order(fdata[, 1], fdata[, 2]), ] | |
orig_names <- colnames(fdata) | |
colnames(fdata) <- c("x", "y", "z") | |
fdata <- as.data.frame(fdata) |
#mlpack on Windows
mlpack, while not designed with Windows as a specific target, can still be built and run on Windows with some configuration. This document details the steps necessary to get MLPACK compiled using MinGW64.
#Prerequisites
CFLAGS += -O3 -Wall -pipe -pedantic | |
CXXFLAGS += -O3 -Wall -pipe -Wno-unused -pedantic | |
VER=-4.8 | |
CCACHE=ccache | |
CC=$(CCACHE) gcc$(VER) | |
CXX=$(CCACHE) g++$(VER) | |
SHLIB_CXXLD=g++$(VER) | |
FC=ccache gfortran$(VER) | |
F77=$(CCACHE) gfortran$(VER) | |
MAKE=make -j8 |
find.funs <-function(pos = 1, ..., exclude.mcache = TRUE, mode = 'function') { | |
findo <- function(pos2) { | |
o <- named(lsall(pos = pos2, ...)) | |
if (!length(o)) | |
return(character(0)) | |
# keep if exists | |
keep <- sapply(o, exists, where = pos2, mode = mode, inherits = FALSE) | |
if (!any(keep)) |
// boost graph serialization example | |
// g++ boost_graph_serialize.cpp -lboost_serialization -o test | |
#include <iostream> | |
#include <string> | |
#include <iostream> | |
#include <fstream> | |
#include <set> |
require(RCurl) | |
require(XML) | |
webpage <- getURL("https://en.wikipedia.org/wiki/N-gram") | |
webpage <- readLines(tc <- textConnection(webpage)); close(tc) | |
pagetree <- htmlTreeParse(webpage, error=function(...){}, useInternalNodes = TRUE) | |
x <- xpathSApply(pagetree, "//*/p", xmlValue) | |
x <- unlist(strsplit(x, "\n")) | |
x <- gsub("\t","",x) | |
x <- sub("^[[:space:]]*(.*?)[[:space:]]*$", "\\1", x, perl=TRUE) | |
x <- x[!(x %in% c("", "|"))] |
#!/bin/python | |
from collections import OrderedDict | |
def memo(f, k): | |
cache = OrderedDict() | |
def memoized(n): | |
if n not in cache: | |
cache[n] = f(n) | |
if len(cache) > k: | |
del cache[cache.keys()[0]] |
require('tcltk') | |
calcinp ='' | |
mkput = function(sym){ | |
function(...){ | |
calcinp <<- paste(calcinp,sym,sep='') | |
tkconfigure(display,text=calcinp) | |
} | |
} | |
clearit = function(...){ |
# improved list of objects by Dirk | |
.ls.objects <- function (pos = 1, pattern, order.by, | |
decreasing=FALSE, head=FALSE, n=5) { | |
napply <- function(names, fn) sapply(names, function(x) | |
fn(get(x, pos = pos))) | |
names <- ls(pos = pos, pattern = pattern) | |
obj.class <- napply(names, function(x) as.character(class(x))[1]) | |
obj.mode <- napply(names, mode) | |
obj.type <- ifelse(is.na(obj.class), obj.mode, obj.class) | |
obj.size <- napply(names, object.size) |