- 1秒後, 5秒後, 15秒後, 60秒後 みたいなリトライがしたかったので interval に Stream[Int] を渡せるようにしてみた。
- 無限 Stream 渡したら無限 retry もできるね。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
public class Era { | |
@Id | |
public Integer id; | |
public String name; | |
public Interval interval; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.util.Arrays; | |
import java.util.Map.Entry; | |
import java.util.Map; | |
import java.util.stream.Stream; | |
import static java.util.Comparator.comparing; | |
import static java.util.stream.Collectors.groupingBy; | |
import static java.util.stream.Collectors.counting; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OnesFunction { | |
private static LoadingCache<Integer, Integer> cache = CacheBuilder | |
.newBuilder().maximumSize(1000) | |
.expireAfterAccess(10, TimeUnit.MINUTES) | |
.build(new CacheLoader<Integer, Integer>() { | |
@Override | |
public Integer load(final Integer i) throws ExecutionException { | |
return countOnes(i); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package views.html.helper | |
import play.api.templates.Html | |
import play.api.data.Field | |
object repeatWithIndex { | |
def apply(field: Field, min: Int = 1)(f: (Field, Int) => Html) = { | |
val idSeq = if (field.indexes.size >= min) { | |
field.indexes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ExSeq[+A] { | |
self: Seq[A] => | |
def mapBetween[B](f:(A,A)=>B): Iterator[B] = { | |
sliding(2).map(s=>f(s(0),s(1))) | |
} | |
} | |
object ExSeq { |