Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am s-u on github.
  • I am urbanek (https://keybase.io/urbanek) on keybase.
  • I have a public key ASD2nbXlZbLli-nTk_D-Etx6fIpCYWX8njGbTsztRiUGZAo

To claim this, I am signing this object:

@s-u
s-u / gen-S3-export.R
Last active November 11, 2020 01:28
Generate S3Method() exports
## automatic generation of S3Method() exports for a NAMESPACE
all = ls(2)
## find generics
isg = sapply(all, function(o) length(grep("UseMethod", deparse(get(o)))))
gens = names(isg[isg > 0])
## check some most common primitives
for (gen in c("+","-","$","$<-"))
if (any(substr(all, 1, nchar(gen) + 1) == paste0(gen, ".")))
gens = c(gens, gen)
@s-u
s-u / start_api_3.R
Last active June 8, 2020 06:12
start_api_3.R
library(randomForest)
library(jsonlite)
# wczytanie modelu
model <- readRDS("model_rf.RDS")
# API - metody
predict_iris <- function(df) {
df <- as.data.frame(df)
## this is a bug in the client, it uses wrong names - so we have to fix it
@s-u
s-u / R.patch
Created May 18, 2020 02:51
Instrument R_PreserveObject/R_ReleaseObject
Index: src/include/Rinternals.h
===================================================================
--- src/include/Rinternals.h (revision 78478)
+++ src/include/Rinternals.h (working copy)
@@ -1461,9 +1461,15 @@
int R_check_class_etc (SEXP x, const char **valid);
/* preserve objects across GCs */
-void R_PreserveObject(SEXP);
-void R_ReleaseObject(SEXP);
@s-u
s-u / keybase.md
Created February 25, 2019 20:48
keybase.md

Keybase proof

I hereby claim:

  • I am s-u on github.
  • I am urbanek (https://keybase.io/urbanek) on keybase.
  • I have a public key ASBrUJjM6EqXkNxf5xhLpHG34FDrujEI3pe_mjgQOpd8qAo

To claim this, I am signing this object:

@s-u
s-u / budp.c
Created October 5, 2018 02:04
UDP broadcast discovery
/* minimalistic UDP-based broadcast discovery tool
(C)2018 Simon Urbanek <simon.urbanek@R-project.org>
License: MIT
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@s-u
s-u / setup.sh
Last active October 4, 2018 21:34
RCloud install on Ubuntu
## This script is intended to be run on Ubuntu 16.04 LTS or 18.04 LTS
## as an automated way to install basic RCloud without metadata services
## mainly to boostrap compute note VMs
##
## Author: Simon Urbanek <simon.urbanek@R-project.org>
## License: MIT
## install dependencies
sudo apt-get update
sudo apt-get install -y gcc g++ gfortran libcairo-dev libreadline-dev libxt-dev libjpeg-dev \
@s-u
s-u / A.java
Last active January 15, 2016 16:00
Java JSON data frame test example
// simple test case for generating a test data frame in Java in JSON and native form
// uses Java Jsonx API, e.g., compile with -cp javax.json-api-1.0.jar:javax.json-1.0.4.jar
import javax.json.*;
public class A {
public static int n = 1000000;
public static void main(String[] main) {
JsonObjectBuilder ob = Json.createObjectBuilder();
@s-u
s-u / mmap_alloc.c
Created October 22, 2014 15:21
example of using custom mmap allocator in R
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>
#include <Rinternals.h>
#include <R_ext/Rallocators.h>
static void *mmap_alloc(R_allocator_t *allocator, size_t length) {
@s-u
s-u / cache.sh
Last active August 29, 2015 14:04
Cache external dependencies in rCharts
#!/bin/sh
#
# Usage: cache.sh [<prefix>]
#
# This file is intended to be run in the rCharts source
# root. It will plow through rCharts sources and
# pick out all external dependencies, download them
# with cache-* prefix as files and modify .yml
# files to reference them instead of the originals.
# All original .yml files are kept as .yml.orig