Skip to content

Instantly share code, notes, and snippets.

@rahulsom
rahulsom / BlueprintTagLib.groovy
Created June 16, 2011 21:48
Grails TagLib for Blueprint
/**
* Creates blueprint taglib to use blueprint css in a nice and clean way
* For generating css, see https://gist.github.com/1023323
*/
class BlueprintTagLib {
static namespace = "blueprint"
/**
* Uses a blueprint stylesheet set
*/
def use = { attrs, body ->
@rahulsom
rahulsom / AsyncTest.groovy
Created February 3, 2012 20:04
Async Http Client Infinite length connections
@Grapes([
@Grab('com.ning:async-http-client:1.7.0'),
@Grab(group = 'log4j', module = 'log4j', version = '1.2.16')
])
import org.apache.log4j.*
import com.ning.http.client.AsyncHttpClientConfig.Builder
import com.ning.http.client.*
import groovy.json.JsonSlurper
import java.util.concurrent.ExecutorService
@rahulsom
rahulsom / AdtGenerator.groovy
Created May 17, 2012 17:18
Generating random ADT Messages
@Grapes([
@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='0.7.0'),
@Grab('ca.uhn.hapi:hapi-base:2.0-alpha1'),
@Grab('ca.uhn.hapi:hapi-structures-v26:2.0-alpha1')
])
import wslite.rest.RESTClient
import java.security.SecureRandom
import java.text.DecimalFormat
import ca.uhn.hl7v2.app.*
@rahulsom
rahulsom / Demux.groovy
Created June 21, 2012 18:14
HL7 Demuxer
@Grapes([
@Grab('ca.uhn.hapi:hapi-base:1.2'),
@Grab('ca.uhn.hapi:hapi-structures-v26:1.2'),
@Grab('ca.uhn.hapi:hapi-structures-v251:1.2'),
@Grab('ca.uhn.hapi:hapi-structures-v25:1.2'),
@Grab('ca.uhn.hapi:hapi-structures-v24:1.2'),
@Grab('ca.uhn.hapi:hapi-structures-v231:1.2'),
@Grab('ca.uhn.hapi:hapi-structures-v23:1.2'),
@Grab('ca.uhn.hapi:hapi-structures-v22:1.2'),
@Grab('ca.uhn.hapi:hapi-structures-v21:1.2')
@rahulsom
rahulsom / TypeForm.groovy
Created September 26, 2015 23:01
Turn TypeForm data into asciidoctor documents
/**
* TypeForm.groovy
*
* Generates asciidoctor output by analyzing a TypeForm survey
*
* 1. Setup an environment variable TYPEFORM_KEY from the account page on TypeForm.
* 2. Run this script with one arg - the code for your survey, e.g. `cC5Ur1`
* 3. Use Asciidoctor output in StdOut to do whatever you need to do.
*/
import groovy.json.JsonSlurper
@rahulsom
rahulsom / README.md
Created December 11, 2012 17:40
Switching JVMs in Mountain Lion

Switching JVMs in Mountain Lion

Apple made it incredibly difficult to switch JVMs since Mountain Lion. This might make it slightly easier.

Installation

  1. Download jvm.sh to ~/bin
  2. Create an alias for jvm.sh to jvm in ~/.profile or ~/.zshrc or whatever
@rahulsom
rahulsom / output.txt
Created November 14, 2013 06:53
Hapi & LigthHl7Lib Performance Benchmarks
Hapi: 2.604747 ms per cycle
LightHl7Lib: 0.00451332 ms per cycle
@rahulsom
rahulsom / AnonCcd.groovy
Created November 25, 2013 23:55
CDA Anonymizer
import groovy.xml.XmlUtil
import java.security.SecureRandom
import java.text.SimpleDateFormat
void anonymize(Reader reader, Writer writer) {
def xml = new XmlParser().parse(reader)
xml.recordTarget.patientRole.with { patientRole ->
patientRole.id.each {
@rahulsom
rahulsom / sendhl7.groovy
Created February 22, 2016 22:39
Send HL7 Message from file to host:port
@Grab('ca.uhn.hapi:hapi-base:2.1')
@Grab('ca.uhn.hapi:hapi-structures-v26:2.1')
import ca.uhn.hl7v2.DefaultHapiContext
import ca.uhn.hl7v2.HapiContext
import ca.uhn.hl7v2.app.ConnectionData
import ca.uhn.hl7v2.llp.LowerLayerProtocol
import ca.uhn.hl7v2.llp.MinLowerLayerProtocol
import ca.uhn.hl7v2.validation.builder.support.NoValidationBuilder
def cli = new CliBuilder()
@rahulsom
rahulsom / ssh-tunnel.sh
Last active February 28, 2016 13:33
SSH Tunneling
#!/bin/bash
#
# SSH Tunnel Manager
#
# SSH Flags:
# f - Force to background.
# N - Execute no commands. Don't open shell.
# q - Run quietly.
# T - Don't allocate pseudo TTY.
# R - Reverse Proxy.