Skip to content

Instantly share code, notes, and snippets.

@amirmv2006
amirmv2006 / ClusterAtomicActionsOnMapWithHazelcast.java
Created July 27, 2018 07:56
a way for parallel process data in a Map.
/**
* Copyright (c) Experian, 2018. All rights reserved.
*/
package com.javadeveloperzone;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.ILock;
import com.hazelcast.core.IMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@amirmv2006
amirmv2006 / Pair.java
Created April 16, 2020 17:27
a Pair of two values, useful for Streams
package ir.amv.enterprise.laas.webapp.utils.fn;
import lombok.Value;
import java.util.Comparator;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;
@Value
@amirmv2006
amirmv2006 / EnhancedListenableFuture.java
Created April 16, 2020 17:45
Enhanced ListenableFuture with map and flatMap methods
package ir.amv.os.vaseline.basics.spring.core.utils.async;
import ir.amv.os.vaseline.basics.core.api.utils.fn.ExceptionalFunction;
import org.springframework.util.concurrent.CompletableToListenableFutureAdapter;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureAdapter;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@amirmv2006
amirmv2006 / LogMockingExtension.java
Created June 11, 2020 18:12
Mock Logging in JUnit 5
package ir.amv.os.test.helper;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.Appender;
import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Stream;
import org.junit.jupiter.api.extension.AfterEachCallback;
@amirmv2006
amirmv2006 / FirestoreRepositoriesHints.java
Created June 20, 2021 07:58
Spring Native Hints for Firestore Repositories
package ir.amv.enterprise.locorepo.common.gcp.adapter;
import com.google.cloud.spring.autoconfigure.firestore.FirestoreRepositoriesAutoConfiguration;
import com.google.cloud.spring.data.firestore.SimpleFirestoreReactiveRepository;
import com.google.cloud.spring.data.firestore.repository.support.FirestoreRepositoryFactoryBean;
import org.springframework.nativex.hint.AccessBits;
import org.springframework.nativex.hint.JdkProxyHint;
import org.springframework.nativex.hint.NativeHint;
import org.springframework.nativex.hint.TypeHint;
import org.springframework.nativex.type.NativeConfiguration;
@amirmv2006
amirmv2006 / FirestoreEntityProcessor.java
Created June 20, 2021 08:04
Firestore Documents Component Processor
/*
* Copyright 2021 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@amirmv2006
amirmv2006 / GcpRepositoryComponentProcessor.java
Created June 20, 2021 08:09
A Component Processor to add native configs for firestore repositories
/*
* Copyright 2019-2021 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@amirmv2006
amirmv2006 / JwtServingTest.kt
Created July 16, 2021 07:01
Mocked JWT server
package ir.amv.enterprise.laas.webapp.common.test.jwt
import com.github.tomakehurst.wiremock.WireMockServer
import com.github.tomakehurst.wiremock.client.WireMock.aResponse
import com.github.tomakehurst.wiremock.client.WireMock.get
import com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo
import com.github.tomakehurst.wiremock.core.WireMockConfiguration
import com.nimbusds.jose.JWSAlgorithm
import com.nimbusds.jose.JWSHeader
import com.nimbusds.jose.crypto.RSASSASigner
@amirmv2006
amirmv2006 / pom.xml
Created September 21, 2021 16:30
put Generated annotation on generated code!
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>anonotate-proto</id>
<phase>generate-sources</phase>
<configuration>
<target>
<replaceregexp match="public(.*) class" flags="g" replace="@javax.annotation.Generated(&quot;protoc&quot;) \0">
@amirmv2006
amirmv2006 / HumanStartingGame.puml
Created December 5, 2021 13:03
Human Starting a Game
@startuml
'https://plantuml.com/sequence-diagram
autonumber
Joystick -> GameService: Start
GameService -> EventBus: GameCreatedEvent
EventBus --> Robot: GameCreatedEvent
Robot -> GameService: Join Computer Player
GameService -> EventBus: GameStartedEvent