Skip to content

Instantly share code, notes, and snippets.


Jon McEwen jonmcewen

  • Naimuri
  • Manchester, UK
View GitHub Profile
View avro serdes
private static <T extends SpecificRecord> T getSpecificRecord(
String json, Schema writersSchema, Class<T> recordClass)
throws IOException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Schema readersSchema = (Schema) recordClass.getMethod("getClassSchema").invoke(null);
Decoder jsonDecoder = DecoderFactory.get().jsonDecoder(writersSchema, json);
ResolvingDecoder resolvingDecoder = DecoderFactory.get().resolvingDecoder(writersSchema, readersSchema, jsonDecoder);
DatumReader<T> reader = new SpecificDatumReader<>(recordClass);
return, resolvingDecoder);
View gist:1bf7751f3f7ba25442e6d7414a9dc3ad
set -e
for dir in ../*
echo "=============="
echo "$dir"
echo "=============="
git --git-dir=$dir/.git --work-tree=$PWD/$dir checkout master
git --git-dir=$dir/.git --work-tree=$PWD/$dir pull
git --git-dir=$dir/.git --work-tree=$PWD/$dir status -s
jonmcewen /
Last active Aug 7, 2019
Hacky bridge to grab dropwizard metrics and stick them into a micrometer registry. Add as a spring-boot Bean
package com.boohoo.esbdefused.metrics;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import com.codahale.metrics.Counter;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.Histogram;
import com.codahale.metrics.Meter;
import com.codahale.metrics.MetricRegistry;
View Java DateTimeFormatter to parse varying number of decimal places
private static final DateTimeFormatter TIME_FORMATTER = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd HH:mm:ss")
.appendFraction(ChronoField.MICRO_OF_SECOND, 0, 6, true).appendPattern("X").toFormatter();
jonmcewen /
Created Dec 16, 2015
Config for ChainedTransactionManager with Camel, JMS, JDBC
import javax.jms.ConnectionFactory;
import javax.sql.DataSource;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.RedeliveryPolicy;
import org.apache.activemq.camel.component.ActiveMQComponent;
import org.apache.activemq.pool.PooledConnectionFactory;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.spring.spi.SpringTransactionPolicy;
import org.springframework.boot.SpringApplication;
jonmcewen /
Created Nov 18, 2015
Example of a CucumberJVM step pattern for capturing a positive or negative number
@When("^an Adjustment of \\+?(-?\\d+) is received$")
public void an_Adjustment_of_x_is_received(int qty) throws Throwable {
//send "qty" as input
jonmcewen /
Created Sep 25, 2015
nagios plugin for spring-boot app status
#!/usr/bin/env python
import requests, sys, getopt
opts, args = getopt.getopt(sys.argv[1:], "p:", ["port="])
except getopt.GetoptError:
print(' -p <port>')
cd "`dirname "$0"`"
nohup java $jmxOpts -jar my-app-1.0.0.jar 1>/dev/null 2>stderr.log &
View gist:60f8576e192a9ff11d24
import static;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
jonmcewen / gist:5270359
Last active Dec 15, 2015
frisby/jasmine-node problem
View gist:5270359
When I run:
$ jasmine-node --verbose .
I get absolutely no output.
Same with:
$ jasmine-node --verbose frisby.spec.js