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 kafka.perf | |
| import java.util.concurrent.{CountDownLatch, Executors} | |
| import java.util.concurrent.atomic.AtomicLong | |
| import kafka.producer._ | |
| import org.apache.log4j.Logger | |
| import kafka.message.{CompressionCodec, Message} | |
| import java.text.SimpleDateFormat | |
| import kafka.serializer._ | |
| import java.util._ |
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 com.github.lazyval; | |
| public class JavaApi { | |
| public static String foo() { | |
| return "123"; | |
| } | |
| } |
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
| # SBT | |
| boot/ | |
| lib_managed/ | |
| target/ | |
| .history | |
| # Eclipse | |
| .cache | |
| .classpath | |
| .project |
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 scala.util.control.TailCalls._ | |
| def solve(l: List[(Int, Int)]): Int = { | |
| def go(from: Int, to: Int, prevHeight: Int): TailRec[Int] = { | |
| val max = to - from | |
| val currHeight = l.slice(from, to).minBy(_._1)._1 | |
| val hStrokes = currHeight - prevHeight | |
| // not sure it's legal, but in practice it seems that you always have only one item here | |
| val List(split) = l.slice(from, to).filter(_._1 - currHeight == 0).map(_._2) | |
| val indices: List[Int] = from :: split :: split + 1 :: to :: Nil |
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
| #!/bin/bash | |
| countFiles () { | |
| # call the recursive function, throw away stdout and send stderr to stdout | |
| # then sort numerically | |
| countFiles_rec "$1" 2>&1 >/dev/null | sort -nr | |
| } | |
| countFiles_rec () { | |
| local -i nfiles |
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
| kp = 1.2 | |
| ki = 0.9 | |
| kd = 0.3 | |
| set_point = 50 | |
| prev_error = 0 | |
| cumulative_moving_average = 0 | |
| iteration = 0 | |
| def make_iteration(measured): |
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
| class Bar<B> {} |
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 kafka.api.FetchRequestBuilder | |
| import kafka.cluster.Broker | |
| import kafka.javaapi.{FetchRequest, TopicMetadataRequest} | |
| import kafka.javaapi.consumer.SimpleConsumer | |
| import kafka.message.Message | |
| import scala.collection.JavaConverters._ | |
| class Reader(anyBroker: String, topic: String, partition: Int, offset: Int) { | |
| val ClientId = "kafka-fetch-size-client" |
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
| /** | |
| * Collects results of map phase, persists it to temporary storage | |
| * results with same key (globally) can be accessed together | |
| */ | |
| interface Emitter<M> { | |
| void emit(String key, M result); | |
| } |
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
| object Hello extends App { | |
| println("hello scala!") | |
| } |