Skip to content

Instantly share code, notes, and snippets.

@mlist
mlist / RESTful_KeyPathwayMiner.r
Created November 24, 2015 14:15
This R script contains exemplary methods for accessing the KeyPathwayMinerWeb RESTful API defined at http://tomcat.compbio.sdu.dk/keypathwayminer/documentation/rest/
### R functions to consume the KeyPathwayMinerWeb RESTful API ###
### Authors: Markus List and Martin Dissing-Hansen ###
# Package dependencies. Make sure those are installed
library(RCurl)
library(rjson)
library(foreach)
# Helper method for base64 encoding. Needed to transfer network and dataset files #
base64EncFile <- function(fileName){
@mlist
mlist / copy_to_docker.sh
Created February 24, 2015 15:01
copy file to docker container
cd /tmp/somefiles
tar -cv * | docker exec -i elated_hodgkin tar x -C /var/www
@mlist
mlist / createdb.sh
Last active August 29, 2015 14:16
bash script to create a database + user in mysql.
#!/bin/bash
EXPECTED_ARGS=3
E_BADARGS=65
MYSQL=`which mysql`
Q1="CREATE DATABASE IF NOT EXISTS $1;"
Q2="GRANT USAGE ON *.* TO $2@localhost IDENTIFIED BY '$3';"
Q3="GRANT ALL PRIVILEGES ON $1.* TO $2@localhost;"
Q4="FLUSH PRIVILEGES;"
@mlist
mlist / awk.csv.filter.bash
Created May 1, 2014 07:29
How to filter out lines from a CSV file that begin with either CDS or UTR3 using awk, allowing you to process a 2GB file in mere seconds
awk -F, '$1 !~ /(^CDS|^UTR3)/' microT_CDS_data.csv > microT_CDS_data.filtered.csv
@mlist
mlist / miracle.groovy
Created April 8, 2014 12:15
MIRACLE example configuration
dataSource {
driverClassName = 'com.mysql.jdbc.Driver'
url = 'jdbc:mysql://localhost/miracle'
username = 'miracle'
password = 'rppa4ever'
dbCreate = 'update'
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
@mlist
mlist / Rcurl_grails.r
Created December 13, 2013 12:45
how to use RCurl to access a grails controller
authenticate <- function(baseUrl="http://localhost:8080/GrailsApp/", user, password, verbose=F){
require(RCurl)
loginUrl = paste(baseUrl, "login/auth", sep="")
authenticateUrl = paste(baseUrl, "j_spring_security_check", sep="")
cat(paste("trying to authenticate user", user))
agent="Mozilla/5.0"
#Set RCurl pars
curl = getCurlHandle()
@mlist
mlist / TokenUsingController.groovy
Created December 13, 2013 12:43
how to apply security token service in a controller
private def accessAllowed = { securityToken, uuid ->
//check if user is authenticated
if(!springSecurityService.isLoggedIn()){
//alternatively check if a security token is provided
if(!securityToken || securityToken != uuid){
return(false)
}
}
return(true)
@mlist
mlist / SecurityTokenService.groovy
Created December 13, 2013 12:40
SecurityTokenService in grails
class SecurityTokenService {
def getSecurityToken(SomeDomainClass sdc) {
if(!sdc?.uuid){
sdc.uuid = UUID.randomUUID().toString()
sdc.save(flush:true)
}
return sdc.uuid
}
@mlist
mlist / jackson.groovy
Created December 13, 2013 12:34
grails with jackson
def criteria = SomeDomainClass.createCriteria()
def result = criteria.list {
...
}
ObjectMapper mapper = new ObjectMapper()
def jsonResult = mapper.writeValueAsString(result)
response.contentType = "text/json"
render jsonResult
@mlist
mlist / projections.groovy
Created December 13, 2013 12:32
grails projections with alias and left outer join
def criteria = Spot.createCriteria()
def result = criteria.list {
eq("slide.id", params.long("id"))
createAlias('layoutSpot', 'lSpot', CriteriaSpecification.LEFT_JOIN)
createAlias('lSpot.sample', 'smpl', CriteriaSpecification.LEFT_JOIN)
projections {
property "id"
property "signal"
property "block"
property "row"