Skip to content

Instantly share code, notes, and snippets.

@bufferings
bufferings / gist:2769883
Created May 22, 2012 15:46
Groovyの勉強:"Buzzになる数字をn個挙げる"
class LazyList {
def car
private Closure cdr
def LazyList next() { cdr() }
def List take(n) {
def r = []; def l = this
(1..n).each{ r << l.car; l++ }
return r
}
def LazyList filter(Closure pred) {
@bufferings
bufferings / hentai.20121211.user.js
Created December 10, 2012 15:08
For HENTAI Advent Calendar 2012(http://atnd.org/events/33835)
// ==UserScript==
// @match http://famo.us/*
// ==/UserScript==
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
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());
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;
@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 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;
package com.example.demo;
import org.junit.Test;
import java.time.LocalDate;
import java.time.chrono.JapaneseDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.format.ResolverStyle;
import java.util.Locale;