This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In Boot2Docker VM: /var/lib/boot2docker/profile: | |
---- | |
DOCKER_TLS="no" | |
---- | |
On localhost, in .profile: | |
---- | |
DOCKER_HOST=tcp://192.168.59.103:2376 | |
DOCKER_TLS_VERIFY= | |
DOCKER_CERT_PATH=/Users/joost/.boot2docker/certs/boot2docker-vm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IntelliJ template for creating Akka actors: | |
--------START TEMPLATE--------- | |
#if ((${PACKAGE_NAME} && ${PACKAGE_NAME} != ""))package ${PACKAGE_NAME} #end | |
import akka.actor.Actor.Receive | |
import akka.actor.{Props, Actor, ActorLogging} | |
trait ${NAME} { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Custom task to run an application many times. | |
// Add scriptlet into build.sbt | |
lazy val runMany = inputKey[Unit]("Running the app many times. Provide nr of times. Defaults to 10.") | |
runMany in Runtime := { | |
val args: Seq[String] = Def.spaceDelimited("Number of times to run. Default is: 10.").parsed | |
val times = Try { | |
args.head.toInt | |
}.getOrElse(10) | |
println(s"Running $times times...") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Convers any type A to a Java compatible type B if such a conversion exists. | |
* Default they exist for all primitive types. | |
* | |
* Usage: Option(1).asJava[java.lang.Integer] | |
* | |
* The type [B] must be provided because the compiler is aparently not able to determine the wanted java.util.Optional<B> type | |
* since that type is removed due to type erasure. | |
* If you want to keep the type A just do not provide a type B when using ```asJava```. For example for custom Pojos. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Some utility methods to work more easily with Java 8's Streams. | |
*/ | |
public class StreamUtils { | |
private StreamUtils() {} | |
/** | |
* @param coll Collection of items. | |
* @return A String of all items in the collections seperated by a ',' using 'toString' to create |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final Answer DEFAULT_OPTIONAL_EMPTY_ANSWER = invocation -> | |
invocation.getMethod().getReturnType() == Optional.class ? Optional.empty() : null; | |
Mockito.mock(YourClassWithOptionalReturnValues.class, DEFAULT_OPTIONAL_EMPTY_ANSWER); | |
// unfortunately this does not work since Mockito's Answers enum is not extendable (yet, issue 345) | |
@Mock(answer = DEFAULT_OPTIONAL_EMPTY_ANSWER) | |
private YourClassWithOptionalReturnValues mockInstance; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Flatten list to list */ | |
public static final <T, R> Collector<T, List<R>, List<R>> flattenCollector(Function<T,List<R>> mapper) { | |
return Collector.of( | |
() -> new ArrayList<>(), | |
(l, a) -> l.addAll(mapper.apply(a)), | |
(l, r) -> { l.addAll(r); return l; }, | |
Collector.Characteristics.UNORDERED | |
); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package nl.malmberg.test.utils; | |
import java.lang.reflect.Field; | |
/** | |
* Helper class for setting properties via reflection. | |
* Based on Deencapsulation class of JMockit. | |
*/ | |
public class Deencapsulation { |
NewerOlder