Skip to content

Instantly share code, notes, and snippets.

View iamanandkris's full-sized avatar

Anand Krishnan iamanandkris

View GitHub Profile
@iamanandkris
iamanandkris / sbt-benchmark.sh
Created November 28, 2015 20:18 — forked from patriknw/sbt-benchmark.sh
Example of sbt launch script for akka benchmarks
#!/bin/sh
# Run the benchmark with this as sbt start script,
# but change the paths (/home/nordwall)
# ~/bin/sbt-benchmark.sh
# > project akka-actor-tests
# > test-only akka.performance.microbench.TellThroughputPerformanceSpec
export JAVA=/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
export FLAGS="-server -Dfile.encoding=UTF8 -XX:+UseNUMA -XX:+UseCondCardMark -XX:-UseBiasedLocking"
@iamanandkris
iamanandkris / ZioWithStateMonad.scala
Last active December 23, 2021 06:27
Attempt to use State monad within ZIO
import cats.data.State
import scalaz.zio.{DefaultRuntime, Task, ZIO}
type UserID = String
case class UserProfile(name:String)
trait Database[F[_]] {
def lookup(id: UserID): Task[F[UserProfile]]
def update(id: UserID, profile: UserProfile): Task[F[Unit]]
}
import cats.data.{State, StateT}
import scalaz.zio._
type UserID = String
case class UserProfile(name:String)
trait Database {
def lookup(id: UserID): Task[UserProfile]
def update(id: UserID, profile: UserProfile): Task[Unit]
}
import scalaz.zio._
type UserID = String
case class UserProfile(name: String)
//Companion object for below Database Module.
object Database {
// The database module contains the database service:
trait Service {
def lookup(id: UserID): Task[UserProfile]
@iamanandkris
iamanandkris / NodeBehaviourExecutor.scala
Last active May 31, 2020 09:02
Shapeless to dynamically invoke typeclass behaviours on a Generic Type
import shapeless._
import shapeless.ops.coproduct.Inject
// "com.chuusai" %% "shapeless" % "2.3.3"
object NodeBehaviourExecutor extends App {
sealed trait NodeData {
val id: String
}
@iamanandkris
iamanandkris / TestDSImplUsingZIO.scala
Last active May 31, 2020 09:02
Pushing Environment externally to DataSource using ZIO
import zio.{DefaultRuntime, Ref, Task, UIO, ZIO}
type FieldSchema = String
type FieldData = String
type GenerateTimestamp = Long
type GenerateUuid[T] = T
type UserID=String
type AccountID = String
import zio.{Has, Layer, Ref, Task, ZIO, ZLayer}
import zio._
import zio.console._
object ZIOInsteadOfFreeRewrite extends App {
type UserID = String
case class UserProfile(name: String)
//Base trait for all the operations that are to be recorded when running test
trait Operation
//The TestState