Skip to content

Instantly share code, notes, and snippets.

View eeichinger's full-sized avatar

Erich Eichinger eeichinger

View GitHub Profile
@eeichinger
eeichinger / LazyBeanDefinitionDocumentReader.java
Created March 5, 2012 16:06
enforce loading spring beans with default-lazy-init=true
public class LazyBeanDefinitionDocumentReader extends DefaultBeanDefinitionDocumentReader {
@Override
protected BeanDefinitionParserDelegate createHelper(XmlReaderContext readerContext, Element root, BeanDefinitionParserDelegate parentDelegate) {
root.setAttribute("default-lazy-init", "true");
BeanDefinitionParserDelegate delegate = super.createHelper(readerContext, root, parentDelegate);
return delegate;
}
}
@eeichinger
eeichinger / example_request.java
Last active June 28, 2018 08:15
Apache HttpClient 4.5.x Usage with NTLM Proxy Authentication, ignore SSL Certificate
@Test
public void fetch_something() throws Exception {
URI uri = UriBuilder.fromPath(path)
.resolveTemplates(ImmutableMap.<String, Object>builder()
.put("country", VALID_COUNTRY)
.put("language", VALID_LANGUAGE)
.build()
)
.build();
@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 / Immutable Data Types with Jackson and Lombok.md
Last active February 7, 2019 15:56
Example tests and notes for making Jackson work with Lombok

Examples for getting Jackson and Lombok to work together to create immutable data types.

Demonstrates use of:

  • Nullable Types
  • Optional
  • immutable java.util.List
  • immutable array
  • validating custom types on instantiate/unmarshalling
  • use & customize Lombok-@Builder with Jackson
@eeichinger
eeichinger / jetty-pom.xml
Last active April 1, 2019 16:10
Jetty Configuration multiple war contexts and with web.xml override to avoid windows file locking
<?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>org.sample</groupId>
<artifactId>testwebserver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
# from https://stackoverflow.com/questions/22734401/base64-encode-decode-to-from-files-in-chunks-with-python-2-7
#
# write_base64_file_from_file
# write_file_from_base64_file
# - must run with python 2.7
# - must process data in chunks to limit memory consumption
# - base64 data must be JSON compatible, i.e.
# use base64 "modern" interface,
# not base64.encodestring() which contains linefeeds
#
@eeichinger
eeichinger / Makefile
Created April 3, 2019 10:12
Makefile 'init' target for setting up a virtual python environment (using pyenv)
# automatically initialise a local python env
# requires:
# - pyenv installed (see https://github.com/pyenv/pyenv)
# - ./requirements.txt to manage dependencies via pip
PYENV_VERSION:="3.7.2"
all: init
.PHONY: clean
@eeichinger
eeichinger / jenkins-decrypt.groovy
Created October 19, 2016 19:36 — forked from tuxfight3r/jenkins-decrypt.groovy
Decrypting Jenkins Password
#To Decrypt Jenkins Password from credentials.xml
#<username>jenkins</username>
#<passphrase>your-sercret-hash-S0SKVKUuFfUfrY3UhhUC3J</passphrase>
#go to the jenkins url
http://jenkins-host/script
#In the console paste the script
hashed_pw='your-sercret-hash-S0SKVKUuFfUfrY3UhhUC3J'
@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 / 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>') }