Skip to content

Instantly share code, notes, and snippets.

View jeroen's full-sized avatar

Jeroen Ooms jeroen

View GitHub Profile
@jeroen
jeroen / libgit2-solaris.sh
Last active December 12, 2020 19:20
Building libgit2 on Solaris 10
# Install dependencies
sudo pkgutil -i cmake libssh2_dev libssl_dev
# Download latest release
cd ~/Desktop
curl -OL https://github.com/libgit2/libgit2/releases/download/v1.1.0/libgit2-1.1.0.tar.gz
gtar xzf libgit2-1.1.0.tar.gz
cd libgit2-1.1.0
# Patch to use C99 instead of C90
@jeroen
jeroen / downloads.R
Last active January 23, 2021 10:35
Plot reverse dependencies and download statistics
library(cranlogs)
library(dplyr)
library(lubridate)
library(ggplot2)
library(hrbrthemes)
pkgs <- c("curl", "RCurl")
df <- cranlogs::cran_downloads(pkgs, from = '2015-01-01', to = '2020-10-31')
monthly <- df %>% group_by(package = package, date=floor_date(date, "month")) %>%
summarize(count=sum(count))
@jeroen
jeroen / movie.R
Last active October 12, 2020 16:53
Terminal movie
# Run in an R terminal window (not GUI)
con <- socketConnection('towel.blinkenlights.nl', 23, open = 'rb')
repeat{
buf <- readBin(con, raw(), 10)
if(length(buf))
cat(rawToChar(buf))
}
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <unistd.h>
int main() {
float A = 0, B = 0;
float i, j;
int k;
+ make 32-bit
make --no-print-directory -C front-ends Rpwd
make -C ../../include -f Makefile.win version
make Rpwd.exe
/mingw32/bin/gcc -std=gnu99 -I../../include -DR_ARCH='"i386"' -O3 -Wall -pedantic -c rpwd.c -o rpwd.o
/mingw32/bin/windres -i rcico.rc -o rcico.o
/mingw32/bin/gcc -std=gnu99 -s -o Rpwd.exe rpwd.o rcico.o
cp front-ends/Rpwd.exe Rpwd.exe
-------- Building ../../../library/base/R/Rprofile from ../../library/profile/Common.R ../../library/profile/Rprofile.windows--------
mkdir -p ../../../library/base/R
openssl_multihash <- function(con, algos = c('md5', 'sha1', 'sha256', 'sha384', 'sha512')){
if(!isOpen(con)){
open(con, "rb")
on.exit(close(con))
}
states <- lapply(algos, function(algo){
structure(openssl:::md_init(algo), algo = algo)
})
while(length(data <- readBin(con, raw(), 512*1024))){
lapply(states, openssl:::md_feed, data = data)
@jeroen
jeroen / benchmark.R
Created January 14, 2020 12:52
Benchmark graphics devices for image()
plot_x <- function(x){
x11()
image(x)
dev.off()
}
plot_png <- function(x){
png(width = 800, height = 600)
image(x)
dev.off()
library(V8)
library(mapview)
library(geojsonsf)
ct$source("https://cdn.jsdelivr.net/npm/[email protected]/dist/flatgeobuf-geojson.min.js")
ct$source("https://cdn.jsdelivr.net/npm/[email protected]/lib/encoding.min.js")
json = sf_geojson(franconia)
ct$call('flatgeobuf.serialize', JS(json))
#' 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 <-