Skip to content

Instantly share code, notes, and snippets.

View jeroen's full-sized avatar

Jeroen Ooms jeroen

View GitHub Profile
@jeroen
jeroen / v8-wasm.cpp
Created September 29, 2019 18:47
Run wasm in V8 version 7.7
#include <v8.h>
#include <libplatform/libplatform.h>
using v8::HandleScope;
using v8::Isolate;
using v8::MemorySpan;
using v8::WasmModuleObject;
using v8::Context;
using v8::Local;
using v8::Value;
@jeroen
jeroen / wasm.R
Created September 15, 2019 05:24
wasm in R
library(V8)
ctx <- v8()
ctx$eval("
let bytes = new Uint8Array([
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x07, 0x01,
0x60, 0x02, 0x7f, 0x7f, 0x01, 0x7f, 0x03, 0x02, 0x01, 0x00, 0x07,
0x07, 0x01, 0x03, 0x61, 0x64, 0x64, 0x00, 0x00, 0x0a, 0x09, 0x01,
0x07, 0x00, 0x20, 0x00, 0x20, 0x01, 0x6a, 0x0b
]);
let module = new WebAssembly.Module(bytes);
@jeroen
jeroen / arrow-ubuntu.sh
Last active October 24, 2024 06:28
Install arrow on Ubuntu
# Import the GPG key
wget https://dist.apache.org/repos/dist/dev/arrow/KEYS
apt-key add < KEYS
# Install libarrow
DISTRO=$(lsb_release --codename --short)
add-apt-repository "deb [arch=amd64] http://dl.bintray.com/apache/arrow/ubuntu $DISTRO main"
apt-get install libarrow-dev libparquet-dev
# Install the R package
# To start the docker container
docker run -it wch1/r-debug
# Run this inside docker:
cd ~
wget https://dist.apache.org/repos/dist/dev/arrow/KEYS
apt-key add < KEYS
add-apt-repository 'deb [arch=amd64] http://dl.bintray.com/apache/arrow/ubuntu bionic main'
apt-get install libarrow-dev libparquet-dev
Attaching package: ‘arrow’
The following object is masked from ‘package:testthat’:
matches
The following object is masked from ‘package:utils’:
timestamp
@jeroen
jeroen / CMakeError.log
Last active March 7, 2019 11:24
Build poppler on Xenial x64
Determining if the pthread_create exist failed with the following output:
Change Dir: /root/poppler-0.74.0/obj-x86_64-linux-gnu/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_aa88c/fast"
make[2]: Entering directory '/root/poppler-0.74.0/obj-x86_64-linux-gnu/CMakeFiles/CMakeTmp'
/usr/bin/make -f CMakeFiles/cmTC_aa88c.dir/build.make CMakeFiles/cmTC_aa88c.dir/build
make[3]: Entering directory '/root/poppler-0.74.0/obj-x86_64-linux-gnu/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_aa88c.dir/CheckSymbolExists.c.o
/usr/bin/cc -std=c99 -D_DEFAULT_SOURCE -o CMakeFiles/cmTC_aa88c.dir/CheckSymbolExists.c.o -c /root/poppler-0.74.0/obj-x86_64-linux-gnu/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTC_aa88c
parse_streamer <- function(url, cb = print){
con <- curl::curl(url = url)
open(con)
on.exit(close(con))
repeat{
txt <- readLines(con, 1)
if(!length(txt)){
print("All done!")
cb(NULL)
break;
@jeroen
jeroen / example.c
Last active January 8, 2019 19:13
libcurl fd bug
/* Test program to verify that CURLMOPT_MAX_TOTAL_CONNECTIONS works as expected */
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include <math.h>
#include <curl/curl.h>
/* Configure max concurrent connections */
@jeroen
jeroen / rate_captcha.R
Last active November 10, 2018 13:57
Rating captchas
# install.packages(c("magick", "tesseract"))
stopifnot(packageVersion('magick') >= 2.0)
stopifnot(packageVersion('tesseract') >= 4.0)
# Use in rstudio to see captcha images
rate_captcha <- function(n = 10){
success <- rep(NA, n)
for(i in seq_len(n)){
repeat{
img <- magick::image_read('https://issues.apache.org/jira/captcha')
@jeroen
jeroen / reinstall.R
Created August 16, 2018 12:57
Reinstall all opencpu apps (on current or new server)
# Run as user opencpu!! sudo su opencpu
dir.create('/tmp/ocpu-temp')
tmp <- tempfile('session', tmpdir = '/tmp/ocpu-temp')
dir.create(tmp, recursive = TRUE)
sys:::set_tempdir(tmp)
setwd(tempdir())
Sys.setenv(TMPDIR=tempdir(), HOME=tempdir())
# Load Sandbox
sys:::aa_change_profile("opencpu-main")