Skip to content

Instantly share code, notes, and snippets.

View jeroen's full-sized avatar

Jeroen Ooms jeroen

View GitHub Profile
#' My roxy
#'
#' This is an example of how you would use roxygen.
#'
#' ```{r}
#' #' Test example
#' #'
#' #' This is an example. Here is how you embed R code:
#' #'
#' #' ```{r}
@jeroen
jeroen / fft.R
Last active December 11, 2024 17:21
Example of FFT in R (because I always forget)
# Sampling frequency and audio length
freq <- 400
duration <- 5
# radian constant for sin/cos
tau <- 2*pi
# Generate a composite signal (4, 6, 9 hz)
x <- seq(0, duration, length.out = freq*duration)
y <-
@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 */