Skip to content

Instantly share code, notes, and snippets.

View RadoBuransky's full-sized avatar

Rado Buranský RadoBuransky

View GitHub Profile
@RadoBuransky
RadoBuransky / flatMapSyntax.scala
Last active June 21, 2018 18:43
Scala flatMap DSL syntax challenge
// The goal is to find "the best" syntax for line #21
trait M[A] {
def map[B](f: A => B): M[B]
def flatMap[B](f: A => M[B]): M[B]
}
class UseParams2[P1, P2](p1: M[P1], p2: M[P2]) {
def toCall[R](f: Function2[P1, P2, R]): M[R] =
for {
@RadoBuransky
RadoBuransky / SparkStreamingState.scala
Created January 4, 2016 07:09
The idea here is to first create a state stream containing strings and then try to access this state as integers which should crash. But the thing is that the sesond test doesn't "see" state from the first test. Why?
package com.buransky
import _root_.kafka.serializer.StringDecoder
import net.manub.embeddedkafka.EmbeddedKafka
import org.apache.spark.SparkConf
import org.apache.spark.streaming._
import org.apache.spark.streaming.dstream.DStream
import org.apache.spark.streaming.kafka.KafkaUtils
import org.scalatest.FunSuite
@RadoBuransky
RadoBuransky / scala-patmat-slow
Created February 24, 2015 20:49
Very slow Scala code to compile
package com.buransky
sealed trait C
case object C1 extends C
case object C2 extends C
case object C3 extends C
case object C4 extends C
case object C5 extends C
case object C6 extends C
case object C7 extends C
@RadoBuransky
RadoBuransky / dist-play-app-initd
Last active March 24, 2020 20:26
Init.d shell script for Play framework distributed application. Provides start, stop, restart and status commands to control applications packaged using standard "play dist" packaging command.
#!/bin/bash
#
# =========================================================================
# Copyright 2014 Rado Buransky, Dominion Marine Media
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0