Skip to content

Instantly share code, notes, and snippets.

View judoole's full-sized avatar

Ole Christian Langfjæran judoole

View GitHub Profile
@judoole
judoole / Unmarshal.scala
Last active October 6, 2015 09:12
Unmarshal a jax ws response to object
//Using Spring to create a reader. Should be easy to write this yourself.
//file is the xml response you got stripped of SoapEnvelope and SoapBody.
def classpathResource: ClassPathResource = new ClassPathResource(file)
def inputStream: InputStream = classpathResource.getInputStream()
def xmlInputFactory: XMLInputFactory = XMLInputFactory.newInstance()
def xmlReader: XMLStreamReader = xmlInputFactory.createXMLStreamReader(inputStream)
//ObjectFactory you can find in your jax ws generated code
val instance: JAXBContext = JAXBContext.newInstance(classOf[ObjectFactory])
val unmarshaller: Unmarshaller = instance.createUnmarshaller()
@judoole
judoole / update-minor.groovy
Last active November 30, 2015 11:35
Update minor version of a Pipeline
//http://javadoc.jenkins-ci.org/
/*
* Script for upping the minor version of the starting job, named ARTIFACT_PROJECT
* We expect every version to arrive here following this version strategy: major.minor
*/
import hudson.model.*
import jenkins.model.Jenkins
//Get the parameters
def originalVersion = build.buildVariableResolver.resolve("VERSION")
@judoole
judoole / docker-compose.yml
Created August 19, 2015 19:52
Docker compose + Slack
hubot:
build: .
restart: always
links:
- redis:redis
environment:
HUBOT_SLACK_TOKEN: <magic-token-here>
data:
image: redis
command: /bin/true
@judoole
judoole / jira_issues_since_last_tag.sh
Created April 13, 2015 11:41
Find unique Jira issues since last tag. Assumes logs related to Jira task starts with jira id.
git log `git describe --tags --abbrev=0`..HEAD --format=%s | grep -o "^\w*-\d*" | sort | uniq
@judoole
judoole / cucumber-scala-dependency-injection.gradle
Last active August 29, 2015 14:16
Scala Cucumber does not support dependency injection. https://github.com/cucumber/cucumber-jvm/issues/469 A workaround is to use Java or Groovy. This setup worked for me.
dependencies {
testCompile "junit:junit-dep:4.11"
testCompile "info.cukes:cucumber-scala_2.10:1.2.2"//TODO: Can be deleted?
testCompile "info.cukes:cucumber-core:1.2.2"
testCompile 'info.cukes:cucumber-java:1.2.2'
testCompile "info.cukes:cucumber-junit:1.2.2" //TODO: Not needed?
//If you'd like some dependencies
testCompile 'info.cukes:cucumber-spring:1.2.2'
testCompile 'org.springframework:spring-test:4.0.5.RELEASE'
@judoole
judoole / main.js
Created December 14, 2014 20:25
Node Sensortag
var SensorTag = require('sensortag');
connect_and_enable_humidity = function(sensorTag){
console.log('discovered %s', sensorTag);
sensorTag.connect(function() {
console.log('connected');
sensorTag.discoverServicesAndCharacteristics(function() {
console.log('Discovering services')
sensorTag.enableIrTemperature(function(){
sensorTag.on('irTemperatureChange', function(objectTemperature, ambientTemperature){
@judoole
judoole / jenkins
Created August 12, 2014 15:08
jenkins init.d for RHEL
#!/bin/sh
#
# SUSE system statup script for Jenkins
# Copyright (C) 2007 Pascal Bleser
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or (at
# your option) any later version.
#
@judoole
judoole / GitContext.groovy
Last active August 29, 2015 14:01
GGG. Gradle, Groovy and Git. Slap this inside your Gradle-script and you've rolled your own git-plugin.
class GitContext {
@Lazy String branchName = {
def proc = 'git rev-parse --abbrev-ref HEAD'.execute()
proc.waitFor()
assert proc.exitValue() == 0, proc.err.text
return proc.in.text.trim()
}()
def boolean isMasterBranch() {
@judoole
judoole / bashrc
Created March 24, 2014 13:22
Norwegian Locale for bash
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
export LANG="no_NO.UTF-8"
export LC_CTYPE="no_NO.UTF-8"
@judoole
judoole / install-locustio
Created August 27, 2013 14:20
Minumum requirements for locustio on Ubuntu
sudo apt-get install -y python-dev python-pip python-gevent libevent-dev libzmq-dev
sudo pip install pyzmq gevent-zeromq locustio