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
cat ~/.ammonite/predef.sc | |
import java.time._ | |
import scala.concurrent.duration._ | |
import scala.concurrent._ | |
import $ivy.`io.monix::monix:3.0.0` | |
import monix.execution.Scheduler.Implicits.global | |
import monix.eval._ | |
import monix.execution._ |
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
private def send(records: Seq[ProducerRecord[String, V]]): Task[Seq[RecordMetadata]] = | |
Task.create[Seq[RecordMetadata]] { (s, cb) => | |
val results = TrieMap.empty[Long, RecordMetadata] | |
val expectedSize = records.size | |
val asyncCb = Callback.forked(cb)(s) | |
val compositeCancelable = CompositeCancelable() | |
// Forcing asynchronous boundary | |
sc.executeAsync(() => { | |
records.foreach { record => |
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
implicit class TaskExtenstions[A](val task: Task[A]) extends AnyVal { | |
def timed(): Task[A] = { | |
for { | |
startTime <- Task.eval(nanoTime()) | |
result <- task.doOnFinish { | |
case _ => logger.info(nanoTime() - startTime) | |
} | |
} yield result | |
} | |
} |
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 CsvEncoder[A] { | |
def encode(value: A): List[String] | |
} | |
def createEncoder[A](func: A => List[String]): CsvEncoder[A] = { | |
new CsvEncoder[A] { | |
override def encode(value: A) = func(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
<?php | |
class ListElement | |
{ | |
/** | |
* @var ListElement | |
*/ | |
private $next; | |
private $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 Statistics { | |
let minimum: Int | |
let maximum: Int | |
let average: Int | |
init(minimum: Int, maximum: Int, average: Int) { | |
self.minimum = minimum | |
self.maximum = maximum | |
self.average = average | |
} |
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
### Keybase proof | |
I hereby claim: | |
* I am cakper on github. | |
* I am cakper (https://keybase.io/cakper) on keybase. | |
* I have a public key whose fingerprint is E49A 7AB1 A55F 7052 DA92 89B2 363A FBB6 6B77 9714 | |
To claim this, I am signing this object: |
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
protocol Board { | |
func isValidMove(move: (x: Int, y: Int)) -> Bool | |
} |
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
<?php | |
namespace Dcwroc\TaskBundle\InMemory; | |
use Dcwroc\TaskBundle\Entity\Task; | |
use Dcwroc\TaskBundle\Entity\TaskRepository; | |
class InMemoryTaskRepository implements TaskRepository | |
{ | |
/** |
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
<?php | |
namespace Dcwroc\TaskBundle\Entity; | |
use Symfony\Component\Validator\Constraints as Assert; | |
class Task | |
{ | |
/** | |
* @Assert\NotBlank() |
NewerOlder