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 BaseConversion { | |
private static final char[] HEXES = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; | |
public static String getHex(long value) { | |
final StringBuilder hex = new StringBuilder(16); | |
byte[] result = new byte[8]; | |
for (int i = 7; i >= 0; i--) { | |
result[i] = (byte) (value & 0xffL); |
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 cats.data.Ior | |
import cats.Monad | |
import cats.syntax.all._ | |
import fs2.{Pipe, Pull, Stream} | |
def mergeWith[F[_]: Monad, A, B, C]( | |
ls: Stream[F, A], | |
rs: Stream[F, B], | |
)( | |
ok: (A, B) => Boolean, |
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
WITH base_users AS ( ... ), | |
country_users AS ( ... ), | |
todays_users AS ( | |
SELECT | |
HLL_COUNT.INIT(user_id, 19) as sketch | |
FROM pageview_events | |
WHERE | |
_PARTITIONTIME = TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY) | |
country = ... | |
) |
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
it("should handle rebalance with multiple consumers") { | |
withKafka { (config, topic) => | |
createCustomTopic(topic, partitions = 300) | |
val maxP1 = 10000 | |
val maxP2 = 20000 | |
val produced1 = (0 until maxP1).map(n => s"key-$n" -> s"value->$n") | |
val produced2 = (maxP1 until maxP2).map(n => s"key-$n" -> s"value->$n") | |
val producedTotal = produced1.size.toLong + produced2.size.toLong | |
val mkConsumer = (id: String, queue: Queue[IO, CommittableMessage[IO, String, String]]) => |
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
it("should handle rebalance") { | |
withKafka { (config, topic) => | |
createCustomTopic(topic, partitions = 300) | |
val maxP1 = 10000 | |
val maxP2 = 20000 | |
val produced1 = (0 until maxP1).map(n => s"key-$n" -> s"value->$n") | |
val produced2 = (maxP1 until maxP2).map(n => s"key-$n" -> s"value->$n") | |
val producedTotal = produced1.size.toLong + produced2.size.toLong | |
val consumer1 = (queue: Queue[IO, CommittableMessage[IO, String, String]]) => |
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 $ivy.`org.typelevel::cats-core:1.0.1` | |
import $ivy.`org.typelevel::cats-effect:0.9` | |
import cats.effect.IO | |
import cats.implicits._ | |
def f(s: String) = IO { Thread.sleep(1000); s } | |
def timeIO[A](f: IO[A]): A = { | |
val start = System.nanoTime | |
val result = f.unsafeRunSync() |
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
module Main where | |
import System.Environment | |
import qualified RotatingQ as Q | |
import RotatingQ (Queue) | |
breadthFirst :: (a -> [a]) -> a -> [a] | |
breadthFirst b r = bf b [r] | |
bf :: (a -> [a]) -> [a] -> [a] |
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
{ | |
"draw_centered": true, | |
"line_numbers": false, | |
"highlight_line": false, | |
"gutter": false, | |
"spell_check": true, | |
"dictionary": "Packages/Language - English/en_GB.dic", | |
"translate_tabs_to_spaces": true, | |
"caret_style": "smooth", | |
"line_padding_top": 1, |
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
Error:scalac: Error: the compiler instance must have -Yrangepos enabled | |
java.lang.RuntimeException: the compiler instance must have -Yrangepos enabled | |
at scala.sys.package$.error(package.scala:27) | |
at scala.meta.internal.scalahost.v1.online.DatabaseOps$XtensionCompilationUnitDatabase.$anonfun$toDatabase$1(DatabaseOps.scala:20) | |
at scala.meta.internal.scalahost.ReflectionToolkit$CompilationUnitCache.$anonfun$getOrElse$5(ReflectionToolkit.scala:92) | |
at scala.Option.getOrElse(Option.scala:121) |
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
trait Parser[A, B] { | |
def parse(in: A): B | |
} | |
object Parser { | |
implicit val intToStringParser: Parser[Int, String] = | |
(in: Int) => { | |
in.toString | |
} |
NewerOlder