Skip to content

Instantly share code, notes, and snippets.

View eeichinger's full-sized avatar

Erich Eichinger eeichinger

View GitHub Profile
@eeichinger
eeichinger / ActivityStateManagerImpl.java
Created April 8, 2014 14:17
My favorite "use spring to instantiate but register as a static global singleton" solution
@Service("blActivityStateManager")
public class ActivityStateManagerImpl implements ActivityStateManager {
private static ActivityStateManager ACTIVITY_STATE_MANAGER;
public static ActivityStateManager getStateManager() {
return ACTIVITY_STATE_MANAGER;
}
@PostConstruct
@eeichinger
eeichinger / StateServiceImpl.java
Created March 31, 2014 13:44
#microservice best practice
@Service("blStateService")
public class StateServiceImpl implements StateService {
@Resource(name="blStateDao")
protected StateDao stateDao;
public List<State> findStates() {
return stateDao.findStates();
}
@eeichinger
eeichinger / jenkins_list_git_tags_and_branches.groovy
Created March 25, 2014 13:35
Groovy script to list git tags and branches using jenkins' Dynamic Choices Parameter plugin
def gettags = ("git ls-remote -t -h ssh://jenkins@<mygitpath>/repo/some.git feature/*").execute()
return gettags.text.readLines()
.collect { it.split()[1].replaceAll('refs/heads/', '') }
.unique()
.findAll { it.startsWith('<some more pattern>') }
@eeichinger
eeichinger / git file change statistics
Created December 9, 2013 10:52
as someone who regularly gets on site with a client and has to quickly work himself into an existing codebase, I found these tools interesting. I stole them from Greg Young's excellent talk "How to get productive on a project in 24h" at http://www.youtube.com/watch?v=KaLROwp-VDY The change rate of modules and files over time is especially intere…
# find the modules/folders with highest number of changes
git rev-list --objects --all | awk '$2' | sort -k2 | uniq -cf1 | sort -rn | head
# find the files with the highest number of changes
git rev-list --objects --all | awk '$2' | sort -k2 | uniq -cf1 | sort -rn |
while read frequency sample path
do
[ "blob" == "$(git cat-file -t $sample)" ] && echo "$frequency\t$path";
done
@eeichinger
eeichinger / update_vagrant_vsphere_plugin.sh
Created November 1, 2013 11:07
vagrant-vsphere plugin - build script
mkdir ~/tmpbuild
cd ~/tmpbuild
git clone git://github.com/nsidc/vagrant-vsphere.git
cd vagrant-vsphere
gem build vSphere.gemspec
vagrant plugin install vagrant-vsphere-0.0.1
@eeichinger
eeichinger / UnhandledExceptionFilter.java
Last active April 1, 2016 11:20
Suppress calls to sendError to prevent servlet containers from sending error pages to the client
package servletutils;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
@eeichinger
eeichinger / MapBuilderSupport
Last active December 10, 2015 13:48
A Fluent API for manipulating java Maps. Useful for e.g. creating header maps in REST responses.
package utils;
import org.springframework.util.MultiValueMap;
import java.util.List;
import java.util.Map;
/**
* A Fluent API for manipulating arbitrary maps<br/>
*<br/>
@eeichinger
eeichinger / LogbackSocketHubAppender.java
Created November 26, 2012 16:34
A logback SocketHubAppender implementation - shamelessly stolen from log4j and adapted to logback. Just copy & paste into your project
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@eeichinger
eeichinger / ConcordionSpringJunit4ClassRunner.java
Created May 17, 2012 15:56
Spring Test / Concordion integration - integrate Concordion with Spring's test runner
package testsupport;
import org.concordion.api.ResultSummary;
import org.concordion.internal.FixtureRunner;
import org.junit.runner.Description;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@eeichinger
eeichinger / pom.xml
Created May 14, 2012 22:56
configure maven-compiler-plugin with different compilers
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.4</version>
<configuration>
<!--<compilerId>javac</compilerId>-->
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-proc:none</compilerArgument>
</configuration>