Skip to content

Instantly share code, notes, and snippets.

View hannes's full-sized avatar

Hannes Mühleisen hannes

View GitHub Profile
@hannes
hannes / .htaccess
Created February 17, 2015 10:47
Hadoop / Kerberos Proxying
RewriteEngine On
RewriteBase /
RewriteRule ^.*$ proxy.php
# test runner generator from a file with R functions
# some grey magic, <[email protected]>, 2015-04-14
test_runner <- function(fname) {
invisible(tryCatch ({
conn <- textConnection("out", "w")
dput(do.call(fname, envir=test_ns, args=list()), file=conn)
close(conn)
out
}, error=function(e) {
#include <assert.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <math.h>
#include <stdlib.h>
# Test runner generator from a file with R functions
# Hannes Muehleisen, <[email protected]>, 2015-04-14
test_runner <- function(fname) {
invisible(tryCatch ({
conn <- textConnection("out", "w")
dput(do.call(fname, envir=test_ns, args=list()), file=conn)
close(conn)
out
}, error=function(e) {
var https = require('https');
var fs = require('fs');
var net = require('net');
var WebSocketServer = require('websocket').server;
// this works on ubuntu if you set chmod 755 on those files and the private dir
var httpsopts = {
key: fs.readFileSync('/etc/ssl/private/ssl-cert-snakeoil.key'),
cert: fs.readFileSync('/etc/ssl/certs/ssl-cert-snakeoil.pem')
};
day_diff <- function(year, month, day, hour=0, min=0, sec=0, tz="UTC") {
as.numeric(difftime(ISOdatetime(year,month,day,hour,min,sec,tz), ISOdatetime(2000,1,1,12,0,0,"UTC"), units="days"))
}
# gah
d2r <- function(x) x * 0.0174532925
r2d <- function(x) x * 57.2957795
# Swabian power!
kepler <- function(M, e) {
@hannes
hannes / monetdblite.R
Last active November 15, 2015 18:49
MonetDBLite installation and usage example
# Obsolete, See https://www.monetdb.org/blog/monetdblite-r
@hannes
hannes / 60minsdemo-monetdblite-shiny.R
Last active March 1, 2019 17:50
Demo MonetDBLite/Shiny
# updated 2018-01-31, hm
library(MonetDBLite)
library(reshape2)
library(shiny)
library(leaflet)
library(ggplot2)
library(ggthemes)
library(DBI)
library(MonetDB.R)
files <- dir("/Users/hannes/Desktop/PAMAP2_Dataset/Protocol/", pattern="*.dat", full.names=T)
tnames <- paste0("pamap2_", sub("^([^.]*).*", "\\1", basename(files)))
snames <- sub(".*(\\d{3})$", "\\1", tnames)
loadsql <- c("DROP VIEW pamap2", paste0("DROP TABLE ",tnames,"; "), paste0("CREATE TABLE ",tnames," (timestamp float, activityID int, heart_rate int, hand_temp float, hand_acc_16_1 float, hand_acc_16_2 float, hand_acc_16_3 float, hand_acc_6_1 float, hand_acc_6_2 float, hand_acc_6_3 float, hand_gyro_1 float, hand_gyro_2 float, hand_gyro_3 float, hand_mag_1 float, hand_mag_2 float, hand_mag_3 float, hand_or_1 float, hand_or_2 float, hand_or_3 float, hand_or_4 float, chest_temp float, chest_acc_16_1 float, chest_acc_16_2 float, chest_acc_16_3 float, chest_acc_6_1 float, chest_acc_6_2 float, chest_acc_6_3 float, chest_gyro_1 float, chest_gyro_2 float, chest_gyro_3 float, chest_mag_1 float, chest_mag_2 float, chest_mag_3 float, chest_or_1 float, chest_or_2 float, chest_or_3 float, chest
# rm -r /tmp/hmda
install.packages("MonetDBLite")
library(DBI)
dbdir <- "/tmp/hmda"
con <- dbConnect(MonetDBLite::MonetDBLite(), dbdir)
# download at http://homepages.cwi.nl/~hannes/hmda.rds
dd <- readRDS("/tmp/hmda.rds")