Skip to content

Instantly share code, notes, and snippets.

View PiotrZakrzewski's full-sized avatar

Piotr Zakrzewski PiotrZakrzewski

View GitHub Profile
@PiotrZakrzewski
PiotrZakrzewski / MyClassSpec.groovy
Created August 21, 2015 12:57
GitHub Grails Config Exception snippet
package mypackage
import grails.test.mixin.TestFor
import grails.test.mixin.TestMixin
import grails.test.mixin.support.GrailsUnitTestMixin
import spock.lang.*
/**
* See the API for {@link grails.test.mixin.support.GrailsUnitTestMixin} for usage instructions
*/
# -*- coding: utf-8 *-*
import subprocess
import xml.dom.minidom as mdom
import collectiontools.reactions as reactions
sbmlStam = """
<sbml xmlns="http://www.sbml.org/sbml/level2" level="2" version="1" xmlns:html="http://www.w3.org/1999/xhtml">
<model id="%(id)s" name="%(name)s">
<listOfUnitDefinitions>
<unitDefinition id="mmol_per_gDW_per_hr">
<listOfUnits>
@PiotrZakrzewski
PiotrZakrzewski / chunker.py
Created October 2, 2015 12:00
chunker.py
def chunker(seq, size):
return (seq[pos:pos + size] for pos in xrange(0, len(seq), size))
'''
Created on May 20, 2012
@author: Piotr Zakrzewski
'''
import collections
import pygame
import threading
import random
@PiotrZakrzewski
PiotrZakrzewski / initRServe.R
Created October 8, 2015 09:52
Simple script to install and run RServe as a daemon.
install.packages("Rserve") #only the first time
install.packages("jsonlite")#only the first time
library("Rserve")
Rserve(args="--vanilla")
@PiotrZakrzewski
PiotrZakrzewski / mockMethod.groovy
Created October 9, 2015 08:40
Example of mocking a method of a Groovy class.
class SampleService {
def methodA() {
methodB()
}
def methodB() {
return "real method"
}
}
#!/usr/bin/python3
"""
Get a md5 hash of a file (content wise, binary)
"""
import hashlib
def getHash(path):
with open(path,"rb") as infile:
content = infile.read()
hash = hashlib.md5(content).digest()
@PiotrZakrzewski
PiotrZakrzewski / heatmap.r
Created October 16, 2015 08:55
heatmap.r script with test data. Requires gplots. Run main() function after sourcing to make the heatmap.
df <- data.frame(Row.Label= as.character(1:5) , Bio.marker=as.character(2:6), z=11:15, u=26:30)
df2 <- data.frame(Row.Label= as.character(1:5) , Bio.marker=as.character(2:6), z=11:15, u=26:30)
loaded_variables <- list("first one"=df, "second" = df2)
library(gplots)
dataset1color <- "coral3"
dataset2color <- "chartreuse3"
labelColumns <- c("Row.Label","Bio.marker")
@PiotrZakrzewski
PiotrZakrzewski / psql.sh
Last active October 26, 2015 15:07
Connect to Transmart postgres DB
psql -U tm_cz -h localhost transmart
sudo -u postgres psql transmart
@PiotrZakrzewski
PiotrZakrzewski / vect_comphr.py
Created October 30, 2015 10:15
Vector comprehension in python numpy
numpy.fromiter((<some_func>(x) for x in <something>),<dtype>,<size of something>)