Skip to content

Instantly share code, notes, and snippets.

View kkarad's full-sized avatar

Konstantinos Karadamoglou kkarad

View GitHub Profile
@kkarad
kkarad / PrintDnsCacheExpiryTime.java
Last active September 26, 2015 05:47
Find jvm's default dns cache expiry time
public class Foo {
public static void main(String[] args) {
System.out.println(sun.net.InetAddressCachePolicy.get());
}
}
@kkarad
kkarad / Identifiable.java
Last active December 10, 2015 23:38
Implementation of the ReversedEnumMap as described at: http://www.javaspecialists.co.za/archive/Issue113.html. The implementation uses google-guava as a dependency but it can be easily removed.
public interface Identifiable<T> {
T getId();
}
@kkarad
kkarad / fixtail.sh
Last active December 18, 2015 11:09
tail -f fix.log | tr '\1' '|' | grep "whatever"
# for every directory run multiple commands
find . -maxdepth 1 -type d -exec sh -c "cd {} && mvn clean && cd -" \;
#when disk is out of space identify directory which occupies most space
df -h
du -s * | sort -r -n | head -n 10
@kkarad
kkarad / BaseSpringTest.java
Last active March 6, 2019 07:41
SpringTest setup example with mock properties loaded during context initialization
package ork.kkarad.examples;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.mock.env.MockPropertySource;