Skip to content

Instantly share code, notes, and snippets.

View jeroen's full-sized avatar

Jeroen Ooms jeroen

View GitHub Profile
@jeroen
jeroen / app.R
Last active October 23, 2022 02:25
Reoder pdf with drag and drop in shiny
# https://twitter.com/henrikbengtsson/status/1583520708470067201
library(shiny)
library(sortable)
library(pdftools)
library(magick)
# The file to manipulate
pdffile <- tempfile(fileext = '.pdf')
download.file('https://www.uscis.gov/sites/default/files/document/forms/i-9-paper-version.pdf', pdffile)
@jeroen
jeroen / math_to_rd.html
Last active August 3, 2022 08:12
HTML with math svg from KaTeX
<!DOCTYPE html><html><head><title>R: Display math in R documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<link href="/doc/html/prism.css" rel="stylesheet" />
<link rel="stylesheet" href="/doc/html/katex/katex.css">
<script type="text/javascript" src="/doc/html/katex-config.js"></script>
<script defer src="/doc/html/katex/katex.js"
onload="processMathHTML();"></script>
<link rel="stylesheet" type="text/css" href="/doc/html/R.css" />
</head><body><div class="container">
@jeroen
jeroen / validate.R
Last active August 2, 2022 07:51
Validates mathjax using katex
ctx <- V8::v8()
ctx$source('https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js')
ctx$eval('function validate(s){var out = {result: "ok", warnings:[]}; try{console.warn=function(w){out.warnings.push(w);};katex.renderToString(s)} catch (e) {out.result = e.name; out.position = e.position; out.message = e.message}; return out;}')
# Parsing error
ctx$call('validate', "E(y) = \\boldmath{\\mu}")
# OK but with warnings:
ctx$call('validate', "s*ₓᵢ = sₓᵢ √(VIFₓᵢ⁻¹) √((n-1)/(n-p))")
@jeroen
jeroen / Dockerfile
Created May 16, 2022 12:01
Package build errors with parallel make on Ubuntu 18.04
FROM ubuntu:bionic
ENV DEBIAN_FRONTEND noninteractive
RUN \
apt-get update && \
apt-get install -y curl software-properties-common && \
curl https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc && \
add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" && \
apt-get update && \
@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 / pubkeys.R
Created September 14, 2021 18:31
read pubkey from certs
input <- jsonlite::fromJSON('https://www.googleapis.com/robot/v1/metadata/x509/[email protected]')
certs = lapply(input, openssl::read_cert)
certs[[1]]$pubkey
certs[[2]]$pubkey
@jeroen
jeroen / math.Rmd
Last active September 14, 2021 17:45
Test Rmd math server-side, borrowed from https://rpruim.github.io/s341/S19/from-class/MathinRmd.html
---
title: "Rending math to HTML in R using katex"
output:
html_document:
katex: true
self_contained: false
vignette: >
%\VignetteIndexEntry{Rending math to HTML in R using katex}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
@jeroen
jeroen / build2.log
Created August 12, 2021 09:17
build arrow with LTO after pr
Running `R CMD build`...
* checking for file 'C:\Users\jeroen\AppData\Local\Temp\2\RtmpERT2kg\remotesa2c787f773d\jeroen-arrow-b52f493/DESCRIPTION' ... OK
* preparing 'arrow':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking vignette meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building 'arrow_5.0.0.tar.gz'
* installing *source* package 'arrow' ...
@jeroen
jeroen / build.log
Created August 10, 2021 16:56
arrow with lto on mingw-w64 with gcc 10.3.0
> install.packages("arrow", type = 'source')
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://cloud.r-project.org/src/contrib/arrow_5.0.0.tar.gz'
Content length 463913 bytes (453 KB)
downloaded 453 KB
* installing *source* package 'arrow' ...
** package 'arrow' successfully unpacked and MD5 sums checked
** using staged installation
*** Writing Makevars.win
@jeroen
jeroen / test-katex.Rmd
Last active July 13, 2021 19:10 — forked from jmcastagnetto/test-katex.Rmd
Testing the rOpenSci {katex} package
---
title: "Testing rOpenSci katex"
author: "Jesus M. Castagnetto, Jeroen Ooms"
date: "2021-07-12"
output:
html_document:
mathjax: null
---
```{r setup, include=FALSE}