This file contains 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
/** | |
* A type safe wrapper for comparable IDs | |
**/ | |
import java.util.UUID | |
abstract class RefId<T : Comparable<T>> : Comparable<RefId<T>> { | |
abstract val value: T | |
override fun compareTo(other: RefId<T>) = value.compareTo(other.value) |
This file contains 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
class TimingLogger( | |
private val step: Long, | |
private val timeUnit: TimeUnit, | |
private val template: String, | |
private val counterScaler: Long = 1, | |
private val log: (String) -> Unit | |
) { | |
private var tickCounter: Long = 0L | |
private var timeMark = System.nanoTime() |
This file contains 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
/** | |
* List literals and List.get extensions | |
*/ | |
object L { | |
// L[1,2,3,4] | |
inline operator fun <T> get(vararg a:T): List<T> = listOf(*a) | |
} | |
// aList[0..3] |
This file contains 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
DELETE /test | |
GET /test/_analyze | |
{ "field": "categories", "text": "123=Foxes"} | |
PUT /test | |
{ | |
"settings": { | |
"analysis": { | |
"char_filter": { |
This file contains 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 concurrent; | |
/** | |
* java -jar target\benchmarks.jar concurrent -t N -wi 10 -i 20 -rf csv -tu ms -si true | |
*/ | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.Param; | |
import org.openjdk.jmh.annotations.Scope; | |
import org.openjdk.jmh.annotations.State; |
This file contains 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
pkg_url <- "http://cran.r-project.org/bin/macosx/mavericks/contrib/3.1/Rserve_1.7-3.tgz" | |
install.packages(pkg_url, repos = NULL) | |
library(Rserve) | |
Rserve(args="--vanilla") |
This file contains 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.util.Arrays; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.stream.Stream; | |
import static java.util.Arrays.stream; | |
import static java.util.Map.Entry.comparingByValue; | |
import static java.util.function.Function.identity; | |
import static java.util.stream.Collectors.*; |
This file contains 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 StringHashCollisions { | |
public static String padByZeroes(String original, int numberOfExtraZeroes) { | |
int length = original.length(); | |
char[] chars = new char[length + numberOfExtraZeroes]; | |
for (int i = 0; i < length; i++) { | |
chars[i + numberOfExtraZeroes] = original.charAt(i); | |
} | |
return new String(chars); | |
} |
This file contains 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 org.junit.Before; | |
import org.junit.Test; | |
import org.mockito.invocation.InvocationOnMock; | |
import org.mockito.stubbing.Answer; | |
import java.util.LinkedList; | |
import java.util.List; | |
import static org.junit.Assert.*; | |
import static org.mockito.Mockito.*; |