Skip to content

Instantly share code, notes, and snippets.

View joelkuiper's full-sized avatar

Joël Kuiper joelkuiper

View GitHub Profile
@joelkuiper
joelkuiper / Rexample.R
Created October 10, 2012 16:39
R scrap for MTC R package
library('rJava')
library('igraph')
.jinit('../inst/java/mtc-mcmc-0.15-SNAPSHOT-jar-with-dependencies.jar')
source('mtc.rjava.R')
network <- read.mtc.network(file="../inst/extdata/luades-smoking.gemtc")
model <- mtc.model(network)
connections <- sapply(mtc.parameters(model$j.model), function(x) { unlist(strsplit(x, '\\.')) } )[-1,]
vertices <- unlist(unique(as.list(connections)))
edges <- apply(connections, c(1,dim(connections)[1]), function(x) { connections[connections == x] <- which(vertices == x) - 1 })
(require '[taoensso.carmine :as car])
(require '[clojure.data.csv :as csv])
(def tree-x (csv/read-csv (io/reader (io/resource "../resources/tree-x.csv")) :separator \;))
(def label-x (csv/read-csv (io/reader (io/resource "../resources/label-x.csv")) :separator \;))
(defn get-labels [csv]
(reduce (fn [m [level term id]] (conj m term)) #{} csv))
(def all-labels (get-labels tree-x))
(def top-labels (get-labels label-x))
@joelkuiper
joelkuiper / gist:4160202
Created November 28, 2012 09:51
Convert MeSH disease tree to OBO Format
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:local="local" exclude-result-prefixes="#all" >
<xsl:output method="html" indent="no"/>
<xsl:strip-space elements="*"/>
<xsl:key name="TreeRef" match="//TreeNumberList/TreeNumber" use="../../DescriptorName"></xsl:key>
<xsl:key name="TreeNode" match="//DescriptorRecord/DescriptorName" use="../TreeNumberList/TreeNumber"></xsl:key>
<xsl:key name="RecordId" match="//DescriptorRecord/DescriptorUI" use="../DescriptorName"></xsl:key>
<xsl:function name="local:getUniqueTreeNumbers">
<xsl:param name="pNodes"/>
@joelkuiper
joelkuiper / run SVM
Created December 6, 2012 11:08
creating AUC
library("ROCR")
library(plyr)
meshClasses <- list.files("partition0")
extractClass <- function(x) { a <- strsplit(x, "\\."); a[[1]][1] }
meshClasses <- sapply(meshClasses, function(x) { extractClass(x) })
getOriginal <- function(i, mesh) {
originalFile <- paste("partition", i, "/", mesh, ".libsvm", sep="")
@joelkuiper
joelkuiper / gist:5005246
Created February 21, 2013 15:00
Don't check any authority for TCP SSL
try {
// Create a trust manager that does not validate certificate chains
final TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
public void checkClientTrusted( final X509Certificate[] chain, final String authType ) {
}
public void checkServerTrusted( final X509Certificate[] chain, final String authType ) {
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
@joelkuiper
joelkuiper / gist:6917330
Last active December 25, 2015 04:29
Dynamic routing with dynamic controllers in AngularJS

I am currently using require.js and angular. Since I have a very long list of custom views, each for a different task. I've cooked up a way of including them dynamically using requirejs.

First a list of tasks is defined, which is provided as a constant. Then for each of the available tasks the file is required using require.js and the controller subsequently registered to the app by using the injector.

Then for each of the tasks a route is added to the route provider (namespaced on a workflow).

    var tasks = {
      'available' : [
@joelkuiper
joelkuiper / gist:7224031
Created October 29, 2013 22:44
redis-benchmark
Downloads/redis-2.8.0-rc5 » redis-benchmark
====== PING_INLINE ======
10000 requests completed in 0.26 seconds
50 parallel clients
3 bytes payload
keep alive: 1
43.95% <= 1 milliseconds
99.98% <= 2 milliseconds
100.00% <= 2 milliseconds
[ { "unMeta" : { } },
[ { "c" : [ 1,
[ "lorem-ipsum",
[ ],
[ ]
],
[ { "c" : "Lorem",
"t" : "Str"
},
{ "c" : [ ],
@joelkuiper
joelkuiper / gist:8398164
Created January 13, 2014 10:47
Kernel panic logs
Anonymous UUID: 53C979F3-160D-7AD3-FA45-98BE02ADBC8C
Wed Jan 8 22:30:54 2014
panic(cpu 2 caller 0xffffff802b85260f): "a freed zone element has been modified: expected 0xdeadbeefdeadbeef but found 0xdeadbee7deadbeef, bits changed 0x800000000, at offset 24 of 72 in zone: ubc_info zone"@/SourceCache/xnu/xnu-2422.1.72/osfmk/kern/zalloc.c:461
Backtrace (CPU 2), Frame : Return Address
0xffffff80a52cb490 : 0xffffff802b822f69
0xffffff80a52cb510 : 0xffffff802b85260f
0xffffff80a52cb570 : 0xffffff802b851d09
0xffffff80a52cb670 : 0xffffff802bbfed11
0xffffff80a52cb6c0 : 0xffffff802b9da0ff
@joelkuiper
joelkuiper / gist:8539695
Last active January 4, 2016 00:09
My Nginx config (SSL, Caching, forwarding)
http {
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;