Skip to content

Instantly share code, notes, and snippets.

View agrueneberg's full-sized avatar

Alexander Grueneberg agrueneberg

View GitHub Profile
@agrueneberg
agrueneberg / tcga-file-search.postman_collection
Last active August 29, 2015 14:03
TCGA File Search API - Query Collection for Postman
{
"id": "4f972238-9569-c553-f31b-d13f05a7af9f",
"name": "TCGA File Search API",
"description": "See https://tcga-data.nci.nih.gov/ccg-data-web/search.jsp?projectId=1",
"order": [
"16f2ef6f-8874-22b6-c702-ff6fc98b31e3",
"a3821414-552b-37e4-8123-b2d8cfd92216",
"1965c0e3-1217-717f-3f2a-b48f24cb7043",
"805128a2-7729-90dd-4ff6-ae9af4a5a633",
"9710c160-0f7e-06a9-695b-2a5601f60404",
@agrueneberg
agrueneberg / parallel.R
Created September 10, 2015 15:20
Parallel Computing in R
library(parallel)
library(BGLR)
library(microbenchmark)
data(mice)
X <- mice.X
y <- mice.pheno$Obesity.BMI
GWAS <- function (i) {
summary(lm(y ~ X[, i]))$coef[2, ]
@agrueneberg
agrueneberg / query.sparql
Last active October 8, 2015 17:08
Federating Patient Data From RPPA Data
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX tcga:<http://purl.org/tcga/core#>
PREFIX tcgameta:<http://purl.org/tcga/metadata#>
PREFIX tcgaclin:<http://purl.org/tcga/clin#>
PREFIX tcgaclinProp:<http://purl.org/tcga/clin#property/>
SELECT ?patientId ?tumorTissueSite ?ageAtInitialDiagnosis ?gender ?race ?vitalStatus
WHERE {
SERVICE <http://agalpha.mathbiol.org:10035/repositories/tcga> {
?file tcga:platform ?platform .
?platform rdfs:label "mda_rppa_core" .
@agrueneberg
agrueneberg / TCGA.R
Created October 25, 2012 17:44
TCGA Toolbox for R
library(RCurl)
library(rjson)
TCGA.get <- function (uri) {
getURI(uri)
}
TCGA.find <- function (query) {
uri <- paste("http://agalpha.mathbiol.org/repositories/tcga?infer=true&query=", URLencode(query, reserved=TRUE), sep="")
response <- fromJSON(getURI(uri, httpheader=c("Accept: application/sparql-results+json")))
@agrueneberg
agrueneberg / gist:4157870
Created November 27, 2012 23:12
@ControllerAdvice in Spring MVC 3.2

Spring MVC 3.2 introduces the @ControllerAdvice component annotation that allows you define single @ExceptionHandler methods for all your controllers.

If you find yourself that the exception handlers are not working the way they are supposed to and you happen to have a clearly separated root and web scope, make sure that that you are including the @ControllerAdvice component in the web scope rather than the root scope, i.e. include org.springframework.web.bind.annotation.ControllerAdvice in context:component-scan:

<context:component-scan base-package="[path]" use-default-filters="false">
  <context:include-filter expression="org.springframework.stereotype.Controller" type="annotation" />
  <context:include-filter expression="org.springframework.web.bind.annotation.ControllerAdvice" type="annotation" />
@agrueneberg
agrueneberg / push-docs.sh
Last active January 10, 2016 05:25
R staticdoc on Travis
#!/bin/bash
set -e
# Only run on normal commits, ignore pull requests
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
# Clone gh-pages branch into inst/web
git clone --branch gh-pages https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git inst/web
# Copy README
cp README.md inst/web
# Run staticdocs
Rscript -e 'library(staticdocs); library(methods); build_site(launch = FALSE)'
@agrueneberg
agrueneberg / gist:3842413
Created October 5, 2012 21:07
UUIDs to Patient Barcodes
library(RCurl)
library(rjson)
# Read sample UUIDs.
uuids <- read.csv(file="~/uuids.csv")
# Convert to character vector.
uuids <- as.vector(t(uuids))
# Query TCGA's UUID to barcode Web Service.
@agrueneberg
agrueneberg / ufw-syncthing
Created January 4, 2015 20:06
ufw app profile for syncthing (to put into /etc/ufw/applications.d/)
[Syncthing]
title=Syncthing
description=Open Source Continuous File Synchronization
ports=22000/tcp|21025/udp
@agrueneberg
agrueneberg / generate-random-matrix.c
Created May 23, 2020 15:28
Generates random binary matrices
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char **argv) {
// Get arguments
if (argc != 4) {
fprintf(stderr, "usage: %s nrows ncols filename\n", argv[0]);
@agrueneberg
agrueneberg / client.html
Last active March 19, 2023 06:48
HMAC-SHA256 example for verifying both the data integrity and the authentication of a request in Node.js and web browsers.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HMAC-SHA256 Example</title>
</head>
<body>
<script src="http://crypto.stanford.edu/sjcl/sjcl.js"></script>
<script>
var sharedSecret, query, signature, hmac, xhr;