Skip to content

Instantly share code, notes, and snippets.

View mrmanc's full-sized avatar

Mark Crossfield mrmanc

View GitHub Profile
@mrmanc
mrmanc / 1AB6305599F94840A97F3E51A04DDF7C
Created November 16, 2016 15:05
Missing cause type in stacktrace
Exception: uk.co.autotrader.shippr.f5.F5AuthorisationException: Authorisation failed whilst trying to Remove pool members from pools 'XXXXXXXXXX, XXXXXXXXXX' using F5 user 'XXXXXXXXXX
Caused by: (401)F5 Authorization Required
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
@mrmanc
mrmanc / gist:5bcbe80549393d1b9ea13c7b3e8974ac
Created May 29, 2016 22:17
JUnit test with multiple anonymous and separately scoped scenarios in one method
import org.junit.Rule;
import org.junit.rules.ErrorCollector;
import static org.assertj.core.api.Assertions.assertThat;
public class ReverseTest {
@Rule
public ErrorCollector collector = new ErrorCollector();
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>vending_machine_java_refuctored</artifactId>
<version>1.0-SNAPSHOT</version>

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@mrmanc
mrmanc / github-org-webhook-conversion.sh
Last active March 23, 2016 18:24
Very rudimentary script to convert the payload of a generic GitHub push event webhook to port 5637 into an API call to notify a Go CD material of an update. Not production ready… intended to be used as a test. You will need to set up a .netrc file in the home directory of the user running the script. https://curl.haxx.se/docs/manpage.html#-n
#!/bin/bash
while true; do
echo -e 'HTTP/1.1 200 OK\r\n' | nc -d -l 5637 | grep git_url | sed -e "s/^.*\(git:\/\/[^\"]*\)\".*$/\1/" | xargs -I {} curl -s --netrc 'https://go.atcloud.io/go/api/material/notify/git' -X POST -d "repository_url={}"
done
@mrmanc
mrmanc / blocked-traces.sh
Created January 5, 2016 10:17
Blocked operations in jstack output
/usr/java/default/bin/jstack $1 | grep -A1 "java.lang.Thread.State: BLOCKED" | grep -v ^-- | grep -v "java.lang.Thread.State: BLOCKED" | sort | uniq -c
@mrmanc
mrmanc / sample-jstat-output
Last active December 15, 2015 17:26
Some jstat output from ‘jstat -gc PID 1s’
S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT
271360.0 268800.0 0.0 215492.3 5035520.0 1933309.9 11184640.0 2746005.2 524288.0 126285.0 11511 1654.373 181 185.540 1839.913
271360.0 268800.0 0.0 215492.3 5035520.0 2185976.4 11184640.0 2746005.2 524288.0 126285.0 11511 1654.373 181 185.540 1839.913
271360.0 268800.0 0.0 215492.3 5035520.0 2304618.9 11184640.0 2746005.2 524288.0 126285.0 11511 1654.373 181 185.540 1839.913
271360.0 268800.0 0.0 215492.3 5035520.0 2366035.2 11184640.0 2746005.2 524288.0 126285.0 11511 1654.373 181 185.540 1839.913
271360.0 268800.0 0.0 215492.3 5035520.0 2488908.0 11184640.0 2746005.2 524288.0 126285.0 11511 1654.373 181 185.540 1839.913
271360.0 268800.0 0.0 215492.3 5035520.0 2644544.6 11184640.0 2746005.2 524288.0 126285.0 11511 1654.373 181 185.540 1839.913
271360.0 268800.0 0.0 215492.3 5035520.0 2746552.0 11184640.0 2746005.2 524288.0 126285.0 115
@mrmanc
mrmanc / ImmutableMap.java
Created November 10, 2015 20:05
ImmutableMap with mapOf()
import java.util.Map;
public abstract class ImmutableMap {
private ImmutableMap() {}
public static <K, V> Map<K, V> mapOf(K k1, V v1) {
return com.google.common.collect.ImmutableMap.of(k1, v1);
}
public static <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2) {
@mrmanc
mrmanc / whisper-calculator.py
Last active October 6, 2015 15:40 — forked from jjmaestro/whisper-calculator.py
whisper-calculator.py:Calculates the size of the whisper storage for the given retention (in frequency:history format)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def archive_to_bytes(archive):
def to_seconds(s):
SECONDS_IN_A = {
's': 1,
'm': 1 * 60,
'h': 1 * 60 * 60,
@mrmanc
mrmanc / xargs-apostrophe
Created November 24, 2014 15:16
Problem caused by apostrophe’s special meaning in xargs
In response to http://askubuntu.com/questions/80244/how-do-i-sort-by-human-readable-sizes-numerically/552976?noredirect=1#answer-552976
mark:~/dutest $ touch "a'b"
mark:~/dutest $ du -s * | sort -n | cut -f2
a'b
mark:~/dutest $ du -s * | sort -n | cut -f2 | xargs du -sh
xargs: unterminated quote