This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' @useDynLib nameOfPackage C_escape_chars | |
deparse_vector3 <- function(x) { | |
.Call(C_escape_chars, x) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This http data stream contains lines of minified JSON data. Therefore | |
# we can batch process this line by line. To speed things up, we actually | |
# process 100 lines at a time, by collapsing them into a JSON array. | |
library(jsonlite) | |
stopifnot(packageVersion("jsonlite") >= "0.9.11") | |
# note that open="r" results in line-by-line reading. | |
gzstream <- gzcon(url("http://78.46.48.103/sample/hourly_14.json.gz", open="r")) | |
batches <- list(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
batchimport <- function(url, batchsize = 1e6) { | |
# Globals | |
stack <- batches <- list(); | |
i <- j <- 1; | |
size <- 0; | |
# Function that parses intermediate json | |
clearstack <- function(all=FALSE){ | |
bigstr <- do.call(paste0, stack); | |
lines <- strsplit(bigstr, "\n")[[1]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We use Ubuntu 14.04 to build a native gcc for win32 with multilib support | |
# | |
# Based on: | |
# http://sourceforge.net/p/mingw-w64/wiki2/Native%20Win64%20compiler/ | |
# http://sourceforge.net/p/mingw-w64/code/HEAD/tree/stable/v3.x/mingw-w64-doc/howto-build/mingw-w64-howto-build.txt?format=raw | |
# | |
# Cross compiling notes: | |
# - The minor version of gcc must match that of our cross compiler (4.8 in this case) | |
# - Important parameters: http://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prevent postfix from prompting for hostname | |
sudo debconf-set-selections <<< "postfix postfix/mailname string your.hostname.com" | |
sudo debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'" | |
sudo apt-get install -y postfix | |
# Install OpenCPU | |
sudo add-apt-repository -y ppa:opencpu/opencpu-2.0 | |
sudo apt-get update | |
sudo apt-get install -y opencpu-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Synchronous implementation of curl() connection | |
curl <- function(url){ | |
con <- rawConnection(raw(0), "r+"); | |
cat("Downloading ") | |
req <- httr::GET(url, httr::write_stream(function(x){ | |
cat(".") | |
writeBin(x, con) | |
})) | |
httr::stop_for_status(req) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# UTF8 tests on Windows | |
# Using R 3.1.2 for win64 with LC_CTYPE=English_United States.1252 | |
library(Rcpp) | |
# Part 1: simply echo a string | |
echo1src <- "#include <Rcpp.h> | |
// [[Rcpp::export]] | |
std::string echo1(std::string src){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Execute this script line by line in your favorite IDE | |
# It does not work via source() | |
library(V8) | |
data(diamonds, package="ggplot2") | |
# Create session | |
ct <- new_context() | |
ct$source("http://cdnjs.cloudflare.com/ajax/libs/crossfilter/1.3.11/crossfilter.min.js") | |
ct$assign("diamonds", diamonds) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Copy this file into config.site ## | |
CC="cc -xc99" | |
CPPFLAGS="-I/opt/csw/include" | |
CFLAGS="-I/opt/csw/include -O -xlibmieee" | |
LDFLAGS="-L/opt/csw/lib" | |
F77=f95 | |
FFLAGS=-O | |
CXX="CC -library=stlport4" | |
CXXFLAGS=-O | |
FC=f95 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> install.packages("RJSONIO") | |
Installing package into '/export/home/jeroen/R/i386-pc-solaris2.11-library/3.2' | |
(as 'lib' is unspecified) | |
--- Please select a CRAN mirror for use in this session --- | |
trying URL 'http://cran.rstudio.com/src/contrib/RJSONIO_1.3-0.tar.gz' | |
Content type 'application/x-gzip' length 1148375 bytes (1.1 MB) | |
opened URL | |
================================================== | |
downloaded 1.1 MB |