Skip to content

Instantly share code, notes, and snippets.

View djvanderlaan's full-sized avatar

Jan van der Laan djvanderlaan

View GitHub Profile
@djvanderlaan
djvanderlaan / index.html
Last active March 1, 2023 02:58
Planetarium
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="http://d3js.org/d3.v3.min.js"></script>
<style>
.orbit {
stroke : #000000;
@djvanderlaan
djvanderlaan / index.html
Last active December 15, 2015 22:49
Identity projection of map in d3.js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="http://d3js.org/d3.v3.min.js"></script>
</head>
<body>
<div id="vis">
</div>
@djvanderlaan
djvanderlaan / one_to_one.R
Created December 8, 2013 13:45
One to one matching using similarity measure
library(lpSolve)
pairs_select <- function(x, y, w, n = 1, m = 1) {
d <- data.frame(x=as.numeric(as.factor(x)), y=as.numeric(as.factor(y)), w=w)
nx <- length(unique(d$x))
ny <- length(unique(d$y))
C <- cbind(c(d$x, d$y + nx), seq_len(nrow(d)))
C <- cbind(C, 1)
res <- lp("max", d$w, dense.const = C, const.dir = rep("<=", nx+ny),
const.rhs = c(rep(n, nx), rep(m, ny)), all.bin=TRUE, use.rw=TRUE)
@djvanderlaan
djvanderlaan / Vagrantfile
Created January 17, 2015 18:56
Vagrant setup for testing R packages with clang and UBSAN
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu-14.04"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
@djvanderlaan
djvanderlaan / jaro.cpp
Last active October 14, 2015 09:21
Jaro similarity score C++ implementation with R-interface
#include <cstring>
#include <cstdlib>
#include <R.h>
#include <Rdefines.h>
double jaro(const char* a, const char* b, double range = 0.5, double match_weight = 1.0,
double trans_weight = 1.0) {
unsigned int la = strlen(a);
unsigned int lb = strlen(b);
// create a buffers; these store for each character in a and b which have
// This example adds handling stylus input to the Custom Drawing example
// from the GTK4 Getting Started.
// See: https://docs.gtk.org/gtk4/getting_started.html#custom-drawing
#include <gtk/gtk.h>
/* Surface to store current scribbles */
@djvanderlaan
djvanderlaan / #codelistdemo.md
Last active March 15, 2024 10:22
Working with codelists demo for datapackage

We have the Iris dataset saved into a data package. There are two resources: the data and the code list for the ‘Species’ variable:

> library(datapackage)
> dp <- opendatapackage("iris")
> dp
[iris] 

Location: <./>