Skip to content

Instantly share code, notes, and snippets.

View nefilim's full-sized avatar

Peter vR nefilim

  • San Francisco, CA
View GitHub Profile
object SuppliedSemigroup {
import cats.kernel.Semigroup
implicit val maxDurationSemigroup: Semigroup[Duration] = Semigroup((a, b) => if (a > b) a else b)
// implicit val optionMonoid: Monoid[Option[Duration]] = cats.kernel.instances.option.catsKernelStdMonoidForOption(maxDurationSemigroup)
def optionDurationCombineSemigroup(rp1: Option[Duration], rp2: Option[Duration])(implicit mo: Semigroup[Option[Duration]]): Option[Duration] = {
mo.combine(rp1, rp2)
}
@nefilim
nefilim / precedence.scala
Last active May 24, 2022 16:59
scala 2 implicit cats type class precendence
object Precendence {
import cats.Monoid
import cats.kernel.Semigroup
import cats.instances.duration._ // <==== comment this out to see the difference
implicit val maxDurationSemigroup: Semigroup[Duration] = Semigroup((a, b) => if (a > b) a else b)
implicit def optionMonoid[A](implicit ev: Semigroup[A]): Monoid[Option[A]] =
new Monoid[Option[A]] {
def empty: Option[A] = None
def combine(x: Option[A], y: Option[A]): Option[A] =
x match {
@DoNotDiscover
class Test1
extends FeatureSpecLike
with Logging
{
feature("main feature") {
logger.info("starting main feature")
scenario("do stuff") {
logger.info("doing some stuff here yo")
import akka.actor._
import akka.routing.{Broadcast, RoundRobinRouter}
import scala.Some
// CONNECTION
case class Connection(production: Boolean = false, id: Int) {
def doStuff(stuff: String) = println(s"stuff [${stuff}] is being done")
}
trait ConnectionProvider {
val map = Map[String, () => Unit]("a" -> proc1, "b" -> proc2)
def proc1() {
println("doing stuff")
}
def proc2() {
println("doing other stuff")
}
implicit def serviceRequest2GeneratedMessage[R <: ServiceResponse, T <: GeneratedMessage](response: R): T = {
response match {
case p:PlayerRegisterResponse => return someFunctionThatMapsToGeneratedMessageDerivedClass(p)
}
}
import sbt._
import Keys._
import sbtprotobuf.{ProtobufPlugin=>PB}
object MyBuild extends Build {
lazy val root = Project(
id = "toastyphoenix",
base = file("."),
settings = Defaults.defaultSettings ++ PB.protobufSettings ++ Seq(
version := "2.5.0"
class MyClass
attr_accessor :vara, :varb
def initialize(hash)
@vara = hash[:vara]
@varb = hash[:varb]
end
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 30100 10820 21460 730368 0 0 0 0 87 208 0 1 99 0 0
0 0 30100 10820 21460 730368 0 0 0 0 101 248 0 0 100 0 0
2 0 30100 10820 21460 730368 0 0 0 0 96 214 0 0 100 0 0
1 0 30100 10820 21460 730368 0 0 0 0 97 223 0 0 100 0 0
0 1 30100 10292 21460 730400 0 0 32 0 122 257 0 1 84 15 0
4 1 30100 10624 21200 729308 0 0 0 0 150 152 0 5 0 95 0
30 1 30100 10664 21200 729308 0 0 0 0 354 40 0 83 0 17 0
30 1 30100 10768 21016 728892 0 0 0 0 386 88 1 94 0 6 0