⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
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 Pattern._ | |
import Family._ | |
def pattern[B](pf: PartialFunction[Name,B]) = new Extractor(pf.lift) | |
val Parents = new Extractor(parents.get) | |
val Children = new Extractor(children.get) | |
"Julie" match { | |
case Parents(p) => "Julies parents are: " + p |
This post aims to document a practical design implementation we came up with when designing some APIs in Scala. Of course the concept is not Scala specific and applies to other functional languages.
If you don't want to go into the full introduction, this post talks about how Applicatives are too restrictive and breaking them into two independent components can be interesting for Contravariant and Invariant Functors. Jump to implementation attached.
We are taking JSON serialization/deserialization as a motivating example.
JsValue
is the name of the type that represents the JSON AST. What we need is to be able to read a JsValue
and produce an A
:
trait Reads[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
# This gist is compatible with Ansible 1.x . | |
# For Ansible 2.x , please check out: | |
# - https://gist.github.com/dmsimard/cd706de198c85a8255f6 | |
# - https://github.com/n0ts/ansible-human_log | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# |
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
Producer | |
Setup | |
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test-rep-one --partitions 6 --replication-factor 1 | |
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test --partitions 6 --replication-factor 3 | |
Single thread, no replication | |
bin/kafka-run-class.sh org.apache.kafka.clients.tools.ProducerPerformance test7 50000000 100 -1 acks=1 bootstrap.servers=esv4-hcl198.grid.linkedin.com:9092 buffer.memory=67108864 batch.size=8196 |
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.parboiled2._ | |
import scala.util.{ Success, Failure } | |
import java.net.{ InetAddress, Inet4Address } | |
import java.time.{ LocalDateTime => LDT } | |
import java.time.format.{ DateTimeFormatter => DTF } | |
object Main extends App { | |
import Logs._ | |
List(l1, l2, l3, l4, l5) foreach { l => |