Skip to content

Instantly share code, notes, and snippets.

View sullivan-'s full-sized avatar

John Sullivan sullivan-

View GitHub Profile
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
### Keybase proof
I hereby claim:
* I am sullivan- on github.
* I am johnsullivanmscs (https://keybase.io/johnsullivanmscs) on keybase.
* I have a public key whose fingerprint is 4B13 C0DD DF42 8389 BDAD 11D9 A36D 692F 7D01 8E5D
To claim this, I am signing this object:
@sullivan-
sullivan- / run.scala
Last active March 13, 2017 16:11
demonstrates odd Iteratee.foreach behavior
object Run extends App {
import cats._
import io.iteratee._
import io.iteratee.internal._
def e = Enumerator.enumVector[Eval, Int]((0 until 10).toVector)
def ge = e.grouped(3)
println("fold ge")
Iteratee.foreach[Eval,Vector[Int]](println).apply(ge).run.value
@sullivan-
sullivan- / crash.scala
Last active May 20, 2016 17:12
crashing the scala compiler
object crash {
class Bar[A]
def bar[A](barOpt: Option[Bar[_ >: A]]): Bar[A] = new Bar
def build[A](barOpt: Option[Bar[_ >: A]]): Bar[A] =
// fix the crash by inserting "[A]" on the following line
bar(barOpt)
package longevity.integration.quickStart
import com.github.nscala_time.time.Imports._
import org.scalatest.OptionValues._
import org.scalatest._
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.concurrent.ScaledTimeSpans
import org.scalatest.time._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import com.typesafe.config.Config
import longevity.context.LongevityContext
import longevity.subdomain._
val bloggingDomain: CoreDomain =
CoreDomain("blogging", EntityTypePool.empty)
val bloggingConfig: Config = loadBloggingConfig()
val bloggingContext = LongevityContext(
bloggingDomain,
Mongo,
trait UserService {
def updateScoreCard(user: User, event: PointScoredEvent): User
}
val userService: UserService = getUserService()
val userState: PState[User] = getUserState()
val updatedState: PState[User] = userState.map { user =>
userService.updateScoreCard(user, event)
}
trait PState[R <: Root] {
def get: R
def map(f: R => R): PState[R]
}
val userState: PState[User] = getUserState()
val user: User = userState.get
val updatedState: PState[User] = userState.map(_.copy(title = Some(newTitle)))
case class User(
id: Long,
username: String,
fullname: String,
email: Email,
profile: Option[UserProfile],
version: Int,
createdBy: String,
createdDate: DateTime,
modifiedBy: String,
import com.github.nscala_time.time.Imports._
import longevity.persistence.PState
import scala.concurrent.Future
val blogState: PState[Blog] = getBlogState()
val recentPosts: Future[Seq[PState[BlogPost]]] = blogPostRepo.retrieveByQuery {
import BlogPost.queryDsl._
import BlogPost.props._
blog eqs blogState.assoc and postDate gt DateTime.now - 1.week