Skip to content

Instantly share code, notes, and snippets.

@paul-lysak
paul-lysak / RhoServicePrioritiesSpec.scala
Created September 28, 2018 14:42
What I expected from Rho routes
package org.http4s
package rho
import cats.effect.IO
import org.specs2.mutable.Specification
class RhoServicePrioritiesSpec extends Specification with RequestRunner {
def construct(method: Method, s: String, h: Header*): Request[IO] =
package sample
import org.json4s.jackson.Serialization
/**
*
* Created by Paul Lysak on 03.08.16.
*/
object EnumDemo {
def main(args: Array[String]): Unit = {
@paul-lysak
paul-lysak / gist:d41dbd8c388b4e5fd97d
Created March 14, 2016 14:25
Example of separation between data and behavior with implicit conversions
SomeData.scala:
case class SomeData(a: Int, b: Int)
AdditionExtensions.scala:
object AdditionExtensions {
implicit class SomeDataConversion(d: SomeData) {
def add = d.a + d.b
def add1 = d.a + d.b +1
...
}
object Test {
def main(args: Array[String]): Unit = {
println("hi there")
val threads = 1 to 3 map {new MyRunner(_)}
// val threads = 1 to 1 map {new MyRunner(_)}
threads.foreach(_.start)
val ts1 = System.currentTimeMillis()
threads.foreach(_.join)
val ts2 = System.currentTimeMillis()
@paul-lysak
paul-lysak / LoggerDemo.scala
Created August 6, 2013 20:08
Illustration of caveats of defining logger in superclass
import com.typesafe.scalalogging.slf4j.Logging
import org.slf4j.LoggerFactory
class SuperClassA extends Logging {
def doSuper {
logger.info("Hi, SuperClassA")
}
}
class SubClassA extends SuperClassA {