Skip to content

Instantly share code, notes, and snippets.

View thomasdarimont's full-sized avatar
🏠
Working from home

Thomas Darimont thomasdarimont

🏠
Working from home
View GitHub Profile
@thomasdarimont
thomasdarimont / InnerWithoutFinal.java
Created October 20, 2014 23:38
Access fields from outer scope within anonymous inner classes without final modifier in Java 8
package de.tutorials.training;
import java.util.Arrays;
public class InnerWithoutFinal {
public static void main(String[] args) {
new Runnable(){
public void run() {
System.out.println(Arrays.toString(args));
@thomasdarimont
thomasdarimont / SimplifySam.java
Created October 21, 2014 09:15
Simplify SAM Type incocations.
Function<String,String> fun = (s)->s;
String funResult = fun.apply("foo"); //conventional way
//String funResult = funResult("foo"); //suggestion
Supplier<String> sup = () -> "bubu";
String supResult = sup.get(); //conventional way
//String supResult = sup(); //suggestion
Consumer<String> con = (s) -> System.out.println(s);
con.accept("bar"); //conventional way
@thomasdarimont
thomasdarimont / cmd_line.txt
Last active August 29, 2015 14:07
Example honest profiler output for a Spring Data MongoDB run.
java -cp $JAVA_HOME/lib/tools.jar:target/honest-profiler.jar com.insightfullogic.honest_profiler.delivery.console.ConsoleEntry -log /Users/tom/Documents/dev/repos/spring/spring-data-examples/rest/starbucks/log.hpl -filter "class: org.springframework.data" > log_sd.txt
@thomasdarimont
thomasdarimont / 000_honest_profiler_osx.md
Last active August 29, 2015 14:07
Poor man's guide to run the honest_profiler under OSX.

#Poor man's guide to run honest_profiler on OSX.

I wanted to play a bit with Richard Warburtons interesting new honest_profiler: https://github.com/RichardWarburton/honest-profiler. Since the wiki page: https://github.com/RichardWarburton/honest-profiler/wiki/How-to-build doesn't contain instructions for building the lib with OSX, I gave it a spin - in a hacky way... I couldn't get the cpp unittests to run so I decided to skip them for now... it works anyways ;-)

Install protobuf

brew install protobuf
#
# makefile for JyNI
#
# Author: Jonathan Hale, Stefan Richthofer
#
#CC = gcc
#CC = g++
CC = gcc
JC = javac
@thomasdarimont
thomasdarimont / AkkaActorApiExample.scala
Created October 29, 2014 12:25
akka Actor API and Actor DSL example for ping pong
package example
import akka.actor._
case object PingMessage
case object PongMessage
case object StartMessage
case object StopMessage
class Ping(pong: ActorRef) extends Actor {
@thomasdarimont
thomasdarimont / Application.java
Last active January 4, 2016 17:27
Application.java
package demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.envers.repository.support.EnversRevisionRepositoryFactoryBean;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@Configuration
@thomasdarimont
thomasdarimont / AbstractEntityBase.java
Last active August 29, 2015 14:09
Example project to reproduce DATAJPA-622.
package demo;
import javax.persistence.MappedSuperclass;
import org.springframework.data.jpa.domain.AbstractPersistable;
@MappedSuperclass
public abstract class AbstractEntityBase extends AbstractPersistable<Long> {
private static final long serialVersionUID = 1L;
@thomasdarimont
thomasdarimont / DefaultMethodProxyExample.java
Last active November 19, 2022 01:24
Examples for dynamic creating instances of interfaces with only default methods
package labs;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Collectors;
@thomasdarimont
thomasdarimont / Application.java
Last active August 29, 2015 14:09
Example for using Spring AOP with a component that declares a dependency via @Autowired on constructor.
package demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan