Skip to content

Instantly share code, notes, and snippets.

View jeroen's full-sized avatar

Jeroen Ooms jeroen

View GitHub Profile
@jeroen
jeroen / bioc.R
Last active March 27, 2024 12:31
Get bioconductor HEAD commits
library(curl)
library(yaml)
parse_raw_gitpack <- function(buf){
con <- rawConnection(buf)
on.exit(close(con))
txt <- readLines(con, warn = FALSE)
stopifnot(grepl('^[0-9a-f]{4}#', txt[1]))
stopifnot(grepl('service=', txt[1]))
if(length(txt) == 2 && txt[2] == '00000000'){
@jeroen
jeroen / tor.R
Last active January 30, 2024 20:45
Using TOR in R
# Installing TOR on mac: brew install tor
# Run TOR on custom port: tor --SOCKSPort 9050
# Check the 'origin' field in the response to verify TOR is working.
library(httr)
GET("https://httpbin.org/get", use_proxy("socks5://localhost:9050"))
# Set proxy in curl
library(curl)
h <- new_handle(proxy = "socks5://localhost:9050")
@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 / arrow-ubuntu.sh
Last active September 6, 2023 05:51
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
@jeroen
jeroen / build-r-arm.sh
Last active September 3, 2023 21:06
Build R-devel for aarch64 in msys2
#!/bin/sh
set -e
set -x
cd ~
export R_CRAN_WEB="https://cran.rstudio.com"
export CRAN_RSYNC='mirrors.nic.cz::CRAN'
# Some prereqs
pacman -S --needed --noconfirm wget git make perl curl texinfo texinfo-tex rsync unzip diffutils
if [ ! -d "aarch64-w64-mingw32.static.posix" ]; then
@jeroen
jeroen / fdtest.c
Last active June 20, 2023 12:42
Test number of file descriptors
#include <curl/curl.h>
#include <stdlib.h>
#include <string.h>
size_t do_nothing(void *contents, size_t sz, size_t nmemb, void *ctx){
return sz * nmemb;
}
CURL *make_handle(char *url){
CURL *handle = curl_easy_init();
@jeroen
jeroen / webr-csv.html
Created April 1, 2023 12:33
webr export csv file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello World! Site Title</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.0/FileSaver.min.js"></script>
<script>
import('https://webr.r-wasm.org/latest/webr.mjs').then(function(x){
const webR = new x.WebR();
@jeroen
jeroen / mingw.sh
Last active March 15, 2023 12:04
mingw-w64 cross compile
# 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
#
@jeroen
jeroen / build-v8-solaris.sh
Last active January 28, 2023 07:20
Building V8 on Solaris 10
#VERSION=v8.17.0
VERSION=v10.24.1
PATH=/opt/csw/bin:$PATH
export CC="gcc"
export CXX="g++"
curl -OL "https://nodejs.org/download/release/${VERSION}/node-${VERSION}.tar.gz"
gunzip node-${VERSION}.tar.gz
rm -Rf node-${VERSION}
gtar xf node-${VERSION}.tar
cd node-${VERSION}
@jeroen
jeroen / Dockerfile
Last active January 17, 2023 21:14
Build libv8 on Fedora
FROM fedora:36
# Simulate the clang location from CRAN
RUN ln -s /usr /usr/local/clang15
RUN dnf install -y clang llvm lld
COPY script.sh .
RUN ./script.sh