Skip to content

Instantly share code, notes, and snippets.

Avatar

Erich Eichinger eeichinger

View GitHub Profile
@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
View Immutable Data Types with Jackson and Lombok.md

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 / assertThatWithSpinWait.java
Last active August 12, 2016 17:19
in asychronous test cases it sometimes is necessary to wait for a condition to occur
View assertThatWithSpinWait.java
@SneakyThrows
private static <T> void assertThatWithSpinWait(Callable<T> actual, Matcher<? super T> matcher, long timeoutMillis) {
long endMillis = System.currentTimeMillis() + timeoutMillis;
while (System.currentTimeMillis() < endMillis) {
try {
assertThat("", actual.call(), matcher);
return;
} catch (AssertionError ignored) {
// ignore
}
@eeichinger
eeichinger / git toolkit
Last active September 8, 2023 05:31
Recursively execute git commands, find unpushed commits, ...
View git toolkit
#
# Description:
# Various additional git utility commands
#
# git recursive <command>:
# from the current working folder search recursively for local git repos and run 'git <command>' on each of them.
#
# git recursive-exec <command>:
# from the current working folder search recursively for local git repos and run '<command>' on each of them.
#
@eeichinger
eeichinger / iswin.py
Created June 14, 2016 15:56
Python script to enum OSX windows and corresponding process id
View iswin.py
#!/usr/bin/env python
# from https://github.com/sjitech/mac_list_windows_pids/blob/master/lswin.py
# requires Quartz framework installed
# $pip install pyobjc-framework-Quartz
import Quartz
#wl = Quartz.CGWindowListCopyWindowInfo( Quartz.kCGWindowListOptionOnScreenOnly | Quartz.kCGWindowListExcludeDesktopElements, Quartz.kCGNullWindowID)
wl = Quartz.CGWindowListCopyWindowInfo( Quartz.kCGWindowListOptionAll, Quartz.kCGNullWindowID)
@eeichinger
eeichinger / sample-resttemplate_pom.xml
Created May 5, 2016 12:06
resttemplate usage sample
View sample-resttemplate_pom.xml
<?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>
<artifactId>sample-resttemplate</artifactId>
<groupId>com.github.eeichinger.blogs</groupId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
@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
View example_request.java
@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 / mapping.json
Last active January 15, 2016 16:37
Wiremock un-gzip recorded traffic
View mapping.json
{
"priority": 10,
"request": {
"method": "ANY",
"urlPattern": ".*"
},
"response": {
"proxyBaseUrl" : "https://other.com",
"additionalProxyRequestHeaders": {
"Accept-Encoding": "identity"
@eeichinger
eeichinger / SomeTest_with_wiremockrule.java
Last active January 15, 2016 16:34
Use WireMockRule in Recording mode against a https backend
View SomeTest_with_wiremockrule.java
@Rule
public WireMockRule wireMockRule = new WireMockRule(wireMockConfig()
.port(0)
.trustStorePath("/path/to/my/keystore.jks")
.trustStorePassword("changeit")
) {
{
enableRecordMappings();
}