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
package de.jugsaar.meeting8.testing.junit.poc;
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
@thomasdarimont
thomasdarimont / FalseSharingDemo.cs
Last active August 29, 2015 14:02
C# FalseSharingEffects
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConcurrencyExamples
{
@thomasdarimont
thomasdarimont / ConfigSettingValue.java
Created June 5, 2014 12:55
Runtime Spring Configuration
package de.tutorials.training.springconfig;
import java.io.Serializable;
import lombok.Data;
@Data
public class ConfigSettingValue implements Serializable {
private static final long serialVersionUID = 1L;
import static org.mockito.Mockito.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class DependencyOverrideExampleTests {
@thomasdarimont
thomasdarimont / Application.java
Last active August 29, 2015 14:03
This gist demonstrates the PoC for the upcoming support for dynamic binding of SpEL expression in string based and derived queries.
package demo;
import java.util.List;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
package de.tutorials.training;
import org.springframework.core.env.SystemEnvironmentPropertySource;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
/**
* [USER=136855]@author[/USER] Thomas Darimont

Initially we also had support for SpEL Expression parameters in query derivation but we decided to leave it out for now, since we had some concerns whether having SpEL expressions in user code is a good idea.

Configure SpEL expression as a bean

@Bean
Expression currentUserEmailAdress(){
	return new SpelExpressionParser().parseExpression("principal?.emailAddress");
}
@thomasdarimont
thomasdarimont / JPAProposal.md
Last active August 29, 2015 14:04
Add support for EL expressions in JPA-QL and native queries.

Add support for EL expressions in JPA-QL and native queries.

This proposal suggests adding support using [EL expressions] (http://docs.oracle.com/javaee/7/tutorial/doc/jsf-el002.htm) in JPA query strings. With this one could define query string templates and dynamic parameter bindings based on EL (Expression Language).

  • Immediate evaluation (via ${...}) could be used to statically alter the query string in cases where the user wants to statically generate a fixed part of a query. This could be used to add query fragments or adjust the name of tables or columns / fields.

  • Deferred evaluation (via #{...}) could be used to dynamically compute a parameter value in cases where the user

@thomasdarimont
thomasdarimont / StringBasedMongoQuery.java
Created July 21, 2014 12:09
Better Quotehandling POC
/*
* Copyright 2011-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@thomasdarimont
thomasdarimont / publicStreamMethods.cypher
Created July 22, 2014 18:29
List all publicly available Methods in JDK 8 that return a Stream with the help of http://jqassistant.org, I wasn't aware of ZipFile.stream() and JarFile.stream() :)
match (t:Type)-[:DECLARES]->(m:Method)-[:RETURNS]->(rt:Type)
where rt.fqn = "java.util.stream.Stream" and t.visibility = 'public' and m.visibility = 'public'
return distinct(t.fqn+"."+m.name) as fqmn