Skip to content

Instantly share code, notes, and snippets.

View danielarantes's full-sized avatar

Daniel de Oliveira Arantes danielarantes

  • Halifax, Nova Scotia - Canada
View GitHub Profile
@atheriel
atheriel / ralloc.bt
Last active April 6, 2020 12:09
Trace allocations of R vectors using bpftrace
#!/usr/bin/env bpftrace
/*
* ralloc - Print allocations of R vectors.
*
* Copyright 2020 Aaron Jacobs
* Licensed under the MIT License or the Apache License, version 2.0.
*/
BEGIN
{
@SymbolixAU
SymbolixAU / distance_benchmarks.R
Last active September 22, 2020 05:52
benchmarks for distance calculations
library(data.table)
library(dplyr)
library(sp)
library(rgeos)
library(UScensus2000tract)
library(geosphere)
library(geodist)
library(data.table)
dyn.load('mmap_alloc.dll')
## create test ~74GB dataset, similar to
## https://github.com/Rdatatable/data.table/wiki/Benchmarks-:-Grouping
N=2e9; K=100
set.seed(1)
DT = list()
# empty mmap columns
# Takes an ordered vector of numeric values and returns a small bar chart made
# out of Unicode block elements. Works well inside dplyr mutate() or summarise()
# calls on grouped data frames.
sparkbar <- function(values) {
span <- max(values) - min(values)
if(span > 0 & !is.na(span)) {
steps <- round(values / (span / 7))
blocks <- c('▁', '▂', '▃', '▄', '▅', '▆', '▇', '█')
paste(sapply(steps - (min(steps) - 1), function(i) blocks[i]), collapse = '')
@olih
olih / jq-cheetsheet.md
Last active July 29, 2024 10:49
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@mojodna
mojodna / README.md
Last active May 17, 2024 12:53
GDAL 2.0 on Amazon Linux
sudo yum -y update
sudo yum-config-manager --enable epel
sudo yum -y install make automake gcc gcc-c++ libcurl-devel proj-devel geos-devel
cd /tmp
curl -L http://download.osgeo.org/gdal/2.0.0/gdal-2.0.0.tar.gz | tar zxf -
cd gdal-2.0.0/
./configure --prefix=/usr/local --without-python
make -j4
sudo make install
@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) {