Skip to content

Instantly share code, notes, and snippets.

package janken;
import java.util.EnumMap;
public class じゃんけん {
public enum Result {
あいこ, 負け, 勝ち
}
@bufferings
bufferings / Hello.java
Last active August 29, 2015 14:20
My Favorite Code
public Result execute(Input in) {
checkNotNull(in, "In is null.");
try {
Integer productId = in.getSelected();
checkProductId(productId);
List<Integer> inputCoins = in.getCoins();
checkInputCoins(inputCoins);
Product product = dao.findById(productId);
package stream;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.BinaryOperator;
import org.glassfish.jersey.internal.util.collection.Ref;
import org.junit.Test;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
@bufferings
bufferings / ExpressionObjectTest.java
Last active May 22, 2016 15:45
Thymeleaf MyExpressionObject
package com.example;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
KStreamBuilder builder = new KStreamBuilder();
KStream<String, String> source = builder.stream("streams-file-input");
KTable<String, Long> counts = source
.flatMapValues(value -> Arrays.asList(value.toLowerCase(Locale.getDefault()).split(" ")))
.map((key, value) -> new KeyValue<>(value, value))
.countByKey("Counts");
counts.to(Serdes.String(), Serdes.Long(), "streams-wordcount-output");
KafkaStreams streams = new KafkaStreams(builder, props());
@bufferings
bufferings / KafkaTest1.java
Last active June 5, 2017 15:09
Kafka Java
package com.example.demo;
import java.util.Arrays;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
import java.util.stream.IntStream;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
package com.example.demo;
import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.kafka.clients.consumer.ConsumerConfig;
package com.example.demo;
import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.kafka.clients.consumer.ConsumerConfig;
package com.example.demo;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;