Skip to content

Instantly share code, notes, and snippets.

View speedcom's full-sized avatar
🏠
Working from home

Mateusz Maciaszek speedcom

🏠
Working from home
View GitHub Profile
@speedcom
speedcom / ErrorFailure.scala
Created April 26, 2016 18:29 — forked from atamborrino/ErrorFailure.scala
Monad transformer for Future[A Or Every[Error]]
package models.error
import org.scalactic._
import scala.concurrent.{ExecutionContext, Future}
import org.scalactic.Accumulation._
trait Error
object FutureOr {
type Errors = Every[Error]
@speedcom
speedcom / ScheduledExecutor.scala
Created January 11, 2016 22:29 — forked from platy/ScheduledExecutor.scala
Scala wrapper around java's ScheduledExecutorService
import java.util.concurrent.ThreadPoolExecutor.AbortPolicy
import java.util.concurrent._
import scala.concurrent.{ Promise, Future }
import scala.concurrent.duration.FiniteDuration
import scala.language.implicitConversions
import scala.util.Try
object ScheduledExecutor {
private val defaultHandler: RejectedExecutionHandler = new AbortPolicy
object ReadSample extends App {
/**
* The readable trait defines how objects can be converted from a string
* representation to the objects instance. For most of the standard types
* we can simply use the toType function of String.
*/
trait Readable[T] {
def read(x: String): T
}
package Boot
import akka.actor.{Cancellable, Actor, ActorSystem, Props}
import akka.stream.{OverflowStrategy, ActorFlowMaterializer}
import akka.stream.actor.ActorSubscriberMessage.{OnComplete, OnNext}
import akka.stream.actor.{ActorSubscriber, OneByOneRequestStrategy, RequestStrategy}
import akka.stream.scaladsl._
import org.akkamon.core.exporters.StatsdExporter
import org.akkamon.core.instruments.{CounterTrait, LoggingTrait, TimingTrait}
@speedcom
speedcom / Example.scala
Last active August 29, 2015 14:18 — forked from noelwelsh/Example.scala
error-handling-web-app
import scalaz.\/
import scalaz.syntax.either._
object Example2 {
// This example simulates error handling for a simple three tier web application
//
// The tiers are:
// - the HTTP service
// - a user authentication layer
// - a database layer
/**
* Part Zero : 10:15 Saturday Night
*
* (In which we will see how to let the type system help you handle failure)...
*
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0)
*/
import scalaz._
import Scalaz._