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.tutorials.training.testing;
import static org.junit.Assert.*;
import java.util.Locale;
import org.junit.Test;
public class ToUpperCaseInTurkeyLocaleTests {
//In org.springframework.data.repository.query.parser.
private static final Pattern PREFIX_TEMPLATE = Pattern
.compile("^(find|read|get|count)((\\p{Lu}|\\P{M}\\p{M}*+).*?)??By");
private static final String KEYWORD_TEMPLATE = "(%s)(?=(\\p{Lu}|\\P{M}\\p{M}*+))";
@thomasdarimont
thomasdarimont / AnnotationMixin.java
Created October 29, 2013 17:11
Prototype of @AnnotationMixing Feature for ProjectLombok
package lombok.experimental;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.ANNOTATION_TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface AnnotationMixin {
@thomasdarimont
thomasdarimont / LambdaPi.java
Last active December 27, 2015 15:59
Approximate PI in almost one line with Lambdas in Java 8 :) - Theory here: http://www.stealthcopter.com/blog/2009/09/python-calculating-pi-using-random-numbers/
package de.tutorials.training.java8.lambda;
import java.util.stream.IntStream;
import static java.lang.Math.*;
import static java.util.concurrent.ThreadLocalRandom.*;
/**
* Author: Thomas Darimont
*/
/*
* Copyright 2013 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
/*
* Copyright 2013 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 / QueryMapperUnitTests.java
Last active January 4, 2016 02:49
Prototypic test case for the race condition in DATAMONGO-686
/**
* @see DATAMONGO-686
*/
@SuppressWarnings("serial")
@Test
public void thereShouldBeNoRaceConditionWhenReusingQueryFromMultipleThreads() throws Exception {
Query query = new Query().addCriteria(where("_id").in("42"));
final CountDownLatch latch = new CountDownLatch(1);
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 / gist:10669696
Last active March 29, 2020 22:07 — forked from debasishg/gist:8172796
Sketching Data Structures
  1. General Background and Overview
@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
{