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
# Proof of concept of using V8 to parse HTML in R | |
# Example taken from rvest readme | |
# Jeroen Ooms, 2015 | |
library(V8) | |
stopifnot(packageVersion("V8") >= "0.4") | |
# Get Document | |
html <- paste(readLines("http://www.imdb.com/title/tt1490017/"), collapse="\n") |
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
# Requires recent version of V8: | |
if( ! require(V8) || packageVersion("V8") < "0.5"){ | |
install.packages("V8") | |
} | |
# Create JavaScript context and load sql.js | |
ct <- new_context() | |
ct$source("https://raw.githubusercontent.com/kripken/sql.js/master/js/sql.js") | |
# Evaluate JavaScript code |
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
library(V8) | |
stopifnot(packageVersion("V8") >= "0.5") | |
# Create V8 context and load viz.js | |
ct <- new_context("window") | |
invisible(ct$source('http://mdaines.github.io/viz.js/viz.js')) | |
# This runs: Viz("digraph { a -> b; }", "svg") | |
svg <- ct$call("Viz", "digraph { a -> b; }", "svg") | |
cat(svg) |
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
library(V8) | |
ct <- new_context() | |
ct$source("http://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.1.1/katex.min.js") | |
html <- ct$call("katex.renderToString", "f(x, \\mu, \\sigma) = \\frac{1}{\\sigma \\sqrt{2\\pi} } e^{ -\\frac{(x-\\mu)^2}{2\\sigma^2}}"); | |
tmp <- tempfile(fileext = ".html") | |
writeLines(c('<html><head><meta charset="UTF-8"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.1.1/katex.min.css"></head><body>', html, '</body></html>'), tmp) | |
browseURL(tmp) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# Load in simple statistics | |
library(V8) | |
ct <- new_context("window") | |
ct$source("https://raw.githubusercontent.com/tmcw/simple-statistics/master/src/simple_statistics.js") | |
# Run Regression | |
ct$assign("mydata", cbind(mtcars$wt, mtcars$mpg)) | |
ct$eval("var lm = ss.linear_regression().data(mydata)") | |
ct$get("[ lm.b(), lm.m() ]") |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Example of embedded iframe</title> | |
<style type="text/css"> | |
body { | |
margin: 0; | |
overflow: hidden; |
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 uses the Debian (or Ubuntu) cross compiler to a native gcc for win32 with multilib support | |
# | |
# Based on: http://sourceforge.net/p/mingw-w64/wiki2/Native%20Win64%20compiler/ | |
# | |
# Cross compiling notes: | |
# - The minor version of gcc must match that of our cross compiler (4.9 in this case) | |
# - Important parameters: http://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html | |
# Prepare system |
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
#include <curl/curl.h> | |
#define LIBCURL_HAS(x) \ | |
(defined(x ## _FIRST) && (x ## _FIRST <= LIBCURL_VERSION_NUM) && \ | |
(!defined(x ## _LAST) || ( x ## _LAST >= LIBCURL_VERSION_NUM))) | |
#define CURLAUTH_ANY_FIRST 0x070a06 /* Added in 7.10.6 */ | |
#define CURLAUTH_ANYSAFE_FIRST 0x070a06 /* Added in 7.10.6 */ | |
#define CURLAUTH_BASIC_FIRST 0x070a06 /* Added in 7.10.6 */ | |
#define CURLAUTH_DIGEST_FIRST 0x070a06 /* Added in 7.10.6 */ |
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
library(curl) | |
# Verbose | |
h <- new_handle() | |
handle_setopt(h, verbose = TRUE) | |
req <- curl_perform("http://httpbin.org/get", handle = h) | |
# Parsing headers | |
parse_headers(req$headers) |