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 MyObserver(actorRef: ActorRef, sourceName: String) | |
(implicit s: Scheduler) extends Subscriber[String] { | |
private[this] def logger = LoggerFactory.getLogger(this.getClass) | |
override implicit def scheduler: Scheduler = s | |
override def onError(ex: Throwable): Unit = { | |
logger.error(s"error happened when processing the stream: error message << ${ex.printStackTrace()} >>") | |
} |
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
override def unsafeSubscribeFn(subscriber: Subscriber[String]): Cancelable = { | |
val bufferedObs = Observable.fromLinesReader(bufferedReader) | |
val obs1 = Observable.interval(1.second) | |
.flatMap(elem => { | |
val out = new PrintStream(socket.getOutputStream) | |
out.print(s"test$elem\n") | |
out.flush() | |
bufferedObs | |
}) |
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
package my.samples.deviceManager | |
import akka.actor.{Actor, ActorLogging, ActorRef, Kill, Props, Terminated} | |
import akka.io.IO | |
import akka.util.ByteString | |
import ch.jodersky.flow.Serial.Command | |
import ch.jodersky.flow.{Parity, Serial, SerialSettings} | |
import my.samples.deviceManager.DeviceExplorerActor.DeviceSerialNumber | |
import my.samples.deviceManager.DeviceWatcherActor.InitializeSerialPort |
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 akka.actor.{Actor, ActorRef, Props, Terminated} | |
import akka.util.ByteString | |
import ch.jodersky.flow.Serial | |
import com.typesafe.scalalogging.LazyLogging | |
import my.samples.deviceManager.DeviceWatcherActor.InitializeSerialPort | |
class DeviceExplorerActor(serialActorRef: ActorRef) | |
extends Actor with LazyLogging { |
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
find . | grep .git | xargs rm -rf |
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
val input = "abccaaaba" // cccaaaba -> ccbaaba -> caaaba -> baaba -> caba -> bba -> bc -> a | |
val distinctChars = input.distinct.sorted.toList | |
@tailrec | |
def reduceString(acc: List[Char], seq: List[Char]): List[Char] = seq match { | |
case Nil => | |
if (acc.toSet.size == 1) acc | |
else reduceString(List.empty[Char], acc) | |
case x :: Nil => |
NewerOlder