Skip to content

Instantly share code, notes, and snippets.

View alexandredantas's full-sized avatar

Alexandre Dantas alexandredantas

View GitHub Profile
@alexandredantas
alexandredantas / config.scala
Created October 29, 2019 01:44
an way to get typesafe configuration through raw map
package config
trait ConfigurationKey[T] {
private[config] final def withConfig(rawConfig: Map[String, String]): Option[T] = read(rawConfig)
protected def read(cfg: Map[String, String]): Option[T]
}
abstract class ConfigurationHolder[Config[_]] {
protected def configMap: Map[String, String]
final def read[T](key: Config[T])(implicit ev: Config[T] <:< ConfigurationKey[T]): Option[T] = key.withConfig(configMap)
@alexandredantas
alexandredantas / tf_monad.scala
Created July 29, 2019 17:17
custom monads for tagless final
import scalaz.std.list._
import zio.IO
import scalaz.{ Applicative, Monad }
import scala.util.Try
package object types{
type ThrowableSafeResult[+T] = IO[Throwable, T]
implicit val ioMonadInstance: Monad[ThrowableSafeResult] = new Monad[ThrowableSafeResult] {
@alexandredantas
alexandredantas / zio-environment-setup.scala
Last active July 22, 2019 21:10
Setting up ZIO environment with custom traits
import zio.clock.Clock
import zio.console.Console
import zio.system.System
import zio.random.Random
import zio.blocking.Blocking
import com.typesafe.config.Config
import zio.Task
import com.typesafe.config.ConfigFactory
import scala.collection.JavaConverters
#
# ASPack 2.29 unpacker via. Dynamic Analysis
#
$:.unshift("C:\\Lib\\metasm")
require 'metasm'
AS229_OEP_PUSH_OFFSET = 0x420
def _msg(m, error = false)