Skip to content

Instantly share code, notes, and snippets.

View spikeheap's full-sized avatar

Ryan Brooks spikeheap

View GitHub Profile
@spikeheap
spikeheap / build.gradle
Created June 17, 2014 12:18
Sample Gradle buildfile for Groovy/IntelliJ support
apply plugin: 'groovy'
apply plugin: 'idea'
project.description = 'something awesome'
project.version = "1.0.0-SNAPSHOT"
project.group = "uk.co.ryanbrooks.example"
repositories {
mavenLocal()
jcenter()
@spikeheap
spikeheap / comparison.groovy
Last active August 29, 2015 14:02
Simple introspection to dig into model inequality in Spock tests
def expected
def actual
def propertiesToCompare = expected.class.declaredFields.findAll { !(it.name =~ /^__/ || it.name =~ /^\$/ || it.name == "metaClass") }
// For each property prints [equality] : [property name] -> [expected value] -|- [actual value]
propertiesToCompare.each { property ->
println "${expected[property.name] == actual[property.name]} : ${property} -> ${expected[property.name]} -|exp: ${actual[property.name]} "
}
@spikeheap
spikeheap / MapConstructorExample.groovy
Last active August 29, 2015 14:02
Refactoring a traditional Java builder to use Groovy's map constructor
// The following
def name = new com.mirth.results.models.NameModel()
name.setPrefix(it[4].toString())
name.setFirst(it[1].toString())
name.setMiddle(it[2].toString())
name.setLast(it[0].toString())
expectedPatient.setName(name)
// Can be written without .toString and using Groovy's map constructor!
expectedPatient.name = new com.mirth.results.models.NameModel(
@spikeheap
spikeheap / comms_api.json
Last active August 29, 2015 14:03
JSON structure for CodeRetreat client-server comms
// Connection request from client, and update every time a test set is run
{
"action": "consumeTestsResults",
"payload": {
"session": 0,
"testsRun": 10,
"testsFailed": 5,
"testsIgnored": 2
}
}
@spikeheap
spikeheap / converted-data.json
Last active August 29, 2015 14:03
Converts WildSwim.com data to GeoJSON format (part of the SusHack2 event)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@spikeheap
spikeheap / CodeRetreatCheatSheet.md
Last active August 29, 2015 14:03
Code Retreat cheat sheet

The cheat sheets in this Gist are for the Oxford Code Retreat on the 6/7/2014.

@spikeheap
spikeheap / arrayContains.js
Created July 5, 2014 16:11
Stupid JavaScript
// The tests.
it('test', function() {
var a1 = [];
a1.push({x:0, y:2});
a1.push({x:1, y:2});
a1.push({x:2, y:2});
a1.push({x:3, y:3});
@spikeheap
spikeheap / subdir_git_status.rb
Last active August 29, 2015 14:04
Get the Git status of all subdirectories of a directory. Prints a simple summary. Not recursive...
#!/usr/bin/env ruby
ARGV.each do |arg|
not_repo = []
unstaged = []
untracked = []
puts "Looking in #{arg}"
all_dirs = Dir.entries(arg).select {|entry| File.directory? File.join(arg,entry) and !(entry =='.' || entry == '..') }
@spikeheap
spikeheap / soapAddMemberToGroup.groovy
Last active December 20, 2016 16:39
A Groovy SOAP client which connects to Mirth and adds a subject to a subject group. This was created as a proof-of-concept of the SOAP interface for a 3rd-party integration project.
@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='1.1.0')
import groovy.xml.*
import wslite.soap.*
import wslite.http.auth.*
def client = new SOAPClient('https://dummy:11443/ClinicalDocumentWSService/ClinicalDocumentWS?wsdl')
client.authorization = new HTTPBasicAuthorization("mirth", "password")
// Grab the latest member list
@spikeheap
spikeheap / gitflow_clean_merged.sh
Created September 19, 2014 13:02
Prune the Git origin of merged feature branches
git branch -r --merged | grep -v master | grep -v develop | grep -v release | sed 's/origin\///' | xargs -n 1 git push --delete origin