Skip to content

Instantly share code, notes, and snippets.

View MarkRBM's full-sized avatar

Mark Moore MarkRBM

View GitHub Profile
@MarkRBM
MarkRBM / rules.scala
Created January 2, 2018 21:27
play json with type parameters
abstract sealed trait Rule[A] {
def roomId: Option[Long] = None
def valid(in: A): Boolean
}
object Rule {
implicit def ruleReads[R, V](implicit rReads: Reads[R], vReads: Reads[V] = null): Reads[Rule[R]] = {
val theVRead = Option(vReads)
val nvr = ???
if (Option(theVRead).isDefined) {
@MarkRBM
MarkRBM / Behavior.scala
Last active May 11, 2018 23:32
FunctionalSensors
Object Behavior {
//assuming I can build a Seq[Vendor]
// I ultimately need a function like this
//Seq[Vendor] => (Seq[SensorRead[_]], Seq[OpStatus])
// so that I can send the reads and statuses off to somewhere else
}
@MarkRBM
MarkRBM / issue.scala
Last active May 16, 2018 04:27
monadic join issue
private def sensorsForRoomsForRange(roomLinks: Seq[SensorRoomLink], from: ZonedDateTime, to: ZonedDateTime): Query[(tables.SensorRoomLinks, tables.SensorDataTable), (SensorRoomLink, UtilizationData), Seq] = {
import IdTable._
val resOne = (for {
(allUtilizationData, groupedByLinkQuery) <- TableQuery[SensorDataTable] join TableQuery[SensorRoomLinks] on (_.sensorId === _.sensorUid) groupBy(_._2)
groupedByLink <- groupedByLinkQuery
rl = groupedByLink._2
d = groupedByLink._1
} yield rl -> d)
resOne
}
[info] 13:55:14.089 ERROR None u.j.logger - $ANSI{green {db=graph-2.0.5}} Error on updating record #26:1 (cluster: plocal cluster: classdef_1)
[info] java.lang.NullPointerException: null
[info] at com.orientechnologies.orient.core.index.sbtreebonsai.local.OSBTreeBonsaiLocal.splitBucket(OSBTreeBonsaiLocal.java:1171)
[info] at com.orientechnologies.orient.core.index.sbtreebonsai.local.OSBTreeBonsaiLocal.put(OSBTreeBonsaiLocal.java:255)
[info] at com.orientechnologies.orient.core.storage.impl.local.paginated.ORidBagUpdateSerializationOperation.execute(ORidBagUpdateSerializationOperation.java:66)
[info] at com.orientechnologies.orient.core.storage.impl.local.paginated.ORecordSerializationContext.executeOperations(ORecordSerializationContext.java:90)
[info] at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.doUpdateRecord(OAbstractPaginatedStorage.java:4026)
[info] at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.commitEntry(OAbstractPaginatedSt
@MarkRBM
MarkRBM / amm.sc
Created September 21, 2018 02:59
Dynamic Transactors
interp.configureCompiler(_.settings.YpartialUnification.value = true)
import $ivy.`org.tpolecat::doobie-core:0.5.3`
import cats._
import cats.effect._
import cats.implicits._
import doobie._
import doobie.implicits._
@MarkRBM
MarkRBM / Trees.scala
Last active February 20, 2019 00:13
trees spec outline
abstract class NodeType
sealed trait StructureTreeNodeType extends NodeType
sealed trait EntityTreeNodeType extends NodeType
//Some Enumberation that describes our entity Types
sealed trait EntityType extends StructureTreeNodeType
case object CountryT extends EntityType
case object BuildingT extends EntityType
case object FloorT extends EntityType
case object RoomT extends EntityType
@MarkRBM
MarkRBM / description.md
Last active March 28, 2019 20:09
Test Project

We have two customers McDonalds and BurgerKing who both use our Reservation and Service Request modules. They have the requirement that they have their own html endpoints that they want to be hit when reservations or service requests are created, updated or deleted.

Given a Json file that represents these customers preferences in the following format

[
{
"appCode": "Mcdonalds", "webhookSettings" : [
{"entity": "RESERVATIONS", "event": CREATED, "endpoint":  "http://httpbin.org/mcdonalds/res/created"},
{"entity": "RESERVATIONS", "event": DELETED, "endpoint":  "http://httpbin.org/mcdonalds/res/deleted"},
{"entity": "SERVICEREQUEST", "event": DELETED, "endpoint":  "http://httpbin.org/mcdonalds/sr/deleted"}
@MarkRBM
MarkRBM / example.scala
Last active April 24, 2019 19:23
http4s websockets with fs2
final class EntityEventsBroker(config: ServerConfig)(
implicit ec: ExecutionContext
) extends EntityEventsStream[IO] {
def consume: Stream[IO, (Key, Value)] =
consumeProcessAndCommit[IO](
TopicSubscription(Set(config.kafkaConfig.topicName)),
KeySerde.deserializer(),
ValueSerde.deserializer(),
config.kafkaConfig.getConsumerSettings
)(processRecord)