Skip to content

Instantly share code, notes, and snippets.

View PiotrZakrzewski's full-sized avatar

Piotr Zakrzewski PiotrZakrzewski

View GitHub Profile
# -*- 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>
'''
Created on May 20, 2012
@author: Piotr Zakrzewski
'''
import collections
import pygame
import threading
import random
#!/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()
#!/usr/bin/env python
import argparse
from numpy.random import random, choice, randint
from numpy import zeros, copyto
import matplotlib.pyplot as plt
plt.ion()
def main():
args = arguments()
@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
*/
@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))
@PiotrZakrzewski
PiotrZakrzewski / rserve.groovy
Last active July 5, 2017 20:00
Code for experimenting with Rserve in groovy.
@Grab(group='org.rosuda', module='Rserve', version='1.7.3')
import org.rosuda.REngine.Rserve.RConnection
def conn = new RConnection()
//list = conn.eval('data.frame(name=c(1, 2, 3))').asNativeJavaObject()
conn.createFile('foo-bar-baz')
conn.eval('getwd()').asString()
@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"
}
}
@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")