Skip to content

Instantly share code, notes, and snippets.

View jeroen's full-sized avatar

Jeroen Ooms jeroen

View GitHub Profile
@jeroen
jeroen / fft.R
Last active March 17, 2026 18:56
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 / libpng_test.c
Created December 27, 2015 19:34 — forked from niw/libpng_test.c
How to read and write PNG file using libpng. Covers trivial method calls like png_set_filler.
/*
* A simple libpng example program
* http://zarb.org/~gc/html/libpng.html
*
* Modified by Yoshimasa Niwa to make it much simpler
* and support all defined color_type.
*
* To build, use the next instruction on OS X.
* $ brew install libpng
* $ clang -lz -lpng15 libpng_test.c
@jeroen
jeroen / Dockerfile
Created February 24, 2026 06:45
Demo base-R Linux binaries on R-4.6
FROM ghcr.io/r-lib/rig/ubuntu-24.04-devel
RUN echo "R_PLATFORM_PKGTYPE=linux.binary.noble-$(arch)" >> "$HOME/.Renviron"
RUN R -e "print(.Platform$pkgType)"
RUN R -e "install.packages('tidyverse', repos = 'https://cran.r-universe.dev')"
RUN R -e "library(tidyverse)"
* installing to library ‘/home/hornik/tmp/R.check/r-devel-clang/Work/build/Packages’
* installing *source* package ‘opencv’ ...
** this is package ‘opencv’ version ‘0.5.1’
** package ‘opencv’ successfully unpacked and MD5 sums checked
** using staged installation
This is pkg-config 1.8.1
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/opencv4 -D_DATA_PREFIX=/usr
Using PKG_LIBS=-lopencv_stitching -lopencv_alphamat -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_cvv -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hdf -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_shape -lopencv_signal -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -
@jeroen
jeroen / mingw.sh
Last active August 27, 2025 11: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 / platform.R
Last active May 14, 2025 13:53
CRAN Packages with NeedsCompilation but unknown platform (no src dir)
df <- as.data.frame(read.dcf(url('https://cran.r-universe.dev/bin/linux/noble-x86_64/4.5/src/contrib/PACKAGES')))
unknown_platform <- df$NeedsCompilation == 'yes' & !grepl('linux', df$Built)
df$Package[unknown_platform]
@jeroen
jeroen / datadeps.R
Last active April 29, 2025 17:00
Bioc packages with 'hard' dependency on data packages
# Bioc packages with 'hard' dependency on data packages
# Please consider making these a 'soft' dependency (aka Suggests) if data is only needed for examples/vignettes.
software <- available.packages(repos = 'https://bioconductor.org/packages/devel/bioc/')
annotation <- available.packages(repos = 'https://bioconductor.org/packages/release/data/annotation')
experiment <- available.packages(repos = 'https://bioconductor.org/packages/release/data/experiment')
datapkgs <- c(row.names(annotation), row.names(experiment))
deps <- tools::package_dependencies(db = software)
datadeps <- sapply(deps, function(x){
intersect(x, datapkgs)
}, simplify = FALSE)
@jeroen
jeroen / clone.c
Created November 26, 2024 11:30
Example to clone with libgit2
//Compile: gcc test.c $(pkg-config --libs --cflags libgit2)
#include <git2.h>
#include <stdio.h>
int main() {
git_libgit2_init();
git_repository *repo = NULL;
int error = git_clone(&repo, "https://github.com/jeroen/sys", "test", NULL);
if (error < 0) {
@jeroen
jeroen / devtest.png
Last active November 8, 2024 21:53
Proposal for development tests
devtest.png
@jeroen
jeroen / magickshiny.R
Last active November 8, 2024 19:54
Magick shiny demo
# Minimal example of Shiny widget using 'magick' images
ui <- fluidPage(
titlePanel("Magick Shiny Demo"),
sidebarLayout(
sidebarPanel(
fileInput("upload", "Upload new image", accept = c('image/png', 'image/jpeg')),
textInput("size", "Size", value = "500x500"),