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
#!/bin/sh | |
exec scala "$0" "$@" | |
!# | |
object Factor extends Enumeration { | |
val Econ = Value("Econ") | |
val Stock = Value("Stock") | |
} | |
import Factor._ |
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 main | |
import akka.stream.{ FlowMaterializer, MaterializerSettings } | |
import akka.stream.scaladsl.{Source,ForeachSink,FlowGraph,FlowGraphImplicits} | |
import akka.actor.ActorSystem | |
import scala.concurrent.{Await, ExecutionContext, Future} | |
import scala.concurrent.duration._ | |
import scala.util.Try | |
object Main extends App { |
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 main | |
import akka.actor.{Actor,ActorSystem, Props} | |
import akka.stream.scaladsl.Source | |
import akka.stream.FlowMaterializer | |
import scala.concurrent.Future | |
import scala.util.{Try,Success,Failure} | |
// import scala.Predef.identity | |
object Counter { |
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
(require 'company) | |
(global-company-mode t) | |
(global-set-key (kbd "s-;") 'company-dabbrev) | |
(global-set-key (kbd "s-:") 'company-complete) | |
(global-auto-complete-mode 0) ;; disable this!!! they fight eachother and it is annoying. |
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 m | |
import akka.actor.{ ActorSystem, Props, ActorRef } | |
import akka.stream.FlowMaterializer | |
import akka.stream.actor.{RequestStrategy, ActorPublisherMessage, ActorSubscriberMessage, ActorSubscriber, MaxInFlightRequestStrategy, ActorPublisher } | |
import akka.stream.scaladsl.{ Sink, Source } | |
import akka.stream.stage._ | |
import scala.annotation.tailrec | |
import scala.collection.mutable.Queue | |
import scala.util.{Failure, Success} |
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 source = Source(RabbitSource( | |
"Worker", | |
rabbitMq, | |
channel(qos = 100), | |
consume(topic("app.domain.class", topics = List(Pg.Table("MainTable").all, Pg.Table("RelatedTable").all))), | |
body(as[PgChange]).map(getPrimaryId))) | |
source. | |
map { case (p, primaryId) => Delivery(p, primaryId) }. | |
mapConcat { delivery => |
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
// RabbitSource in op-rabbit v1.0.0-M9 returns an AckedSource | |
val source = RabbitSource( | |
"Worker", | |
rabbitMq, | |
channel(qos = 100), | |
consume(topic("app.domain.class", topics = List(Pg.Table("MainTable").all, Pg.Table("RelatedTable").all))), | |
body(as[PgChange]).map(getPrimaryId)) | |
source. | |
collect { case Some(i) => i }. |
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 = (Stream.continually(Promise[Unit]) zip Range.inclusive(1, 5)).toList | |
implicit val materializer = ActorMaterializer() | |
val source = AckedSource(input) | |
val Seq(s1, s2) = (1 to 2) map { n => AckedSink.fold[Int, Int](0)(_ + _) } | |
val g = AckedFlowGraph.closed(s1, s2)((m1, m2) => (m1, m2)) { implicit b => | |
(s1, s2) => |
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
// psuedo-code; will not actually compile | |
import com.spingo.op_rabbit.Json4sSupport._ // allows you to use Json4s directly to serialize / deserialize published messages | |
trait MarketOrEv | |
case class Market(mkt_id: Int, ev_id: Int, model_type:”Market”) extends MarketOrEv | |
case class Ev(ev_id: Int, model_type:”Ev”) extends MarketOrEv | |
OlderNewer