Skip to content

Instantly share code, notes, and snippets.

View kevinmeredith's full-sized avatar

Kevin Meredith kevinmeredith

  • https://twitter.com/Gentmen
View GitHub Profile
@kevinmeredith
kevinmeredith / _.md
Last active January 4, 2022 16:25
The Power of Referential Transparency

The Power of Referential Transparency

Acknowledgment

This post uses the excellent Ammonite REPL for Scala REPL.

Thank you, Li Haoyi, for building it!

About the Author

@ import $ivy.`org.typelevel::cats-effect:0.10.1`
import $ivy.$
@ import cats.effect.IO, cats.implicits._
import cats.effect.IO, cats.implicits._
@ val foo: IO[Either[String, Int]] = IO(throw new RuntimeException("!"))
foo: IO[Either[String, Int]] = Delay(ammonite.$sess.cmd2$$$Lambda$2001/359985955@1bbfd42f)
@ foo.attempt
(1) Creating an Engineering Career Ladder
* he rolled out two career ladders in his experience
* he disputes that any company truly has a "flat org"
* notes that Senior Level Engineer is the anchor
* messaging is critical, e.g. important to announce promotions since it indicates importance of career ladder
* comments that general feedback, "you're doing great" isn't worth much. He suggests giving specific feedback on positives or needs-improvement
* Talked about 3 ladders:
- simple
- snowflake

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.

@kevinmeredith
kevinmeredith / scalaz_kleisli.md
Created August 6, 2018 19:36
Understanding Kleisli |||
@ val x: Kleisli[Task, String \/ Int, Boolean] = Kleisli {
    case -\/(_) => Task.now(true)
    case \/-(_) => Task.now(false)
  } 
x: Kleisli[Task, String \/ Int, Boolean] = Kleisli(ammonite.$sess.cmd5$$$Lambda$2811/243334301@38171f9)

@ val x: Kleisli[Task, String, Boolean] = Kleisli { _ => Task.now(true) } 
x: Kleisli[Task, String, Boolean] = Kleisli(ammonite.$sess.cmd6$$$Lambda$2832/1335778574@1bde703a)
@kevinmeredith
kevinmeredith / x.scala
Created May 28, 2018 16:17
Run IO[List[Int]] in Parallel using Ammonite
@ import $ivy.`org.typelevel::cats-effect:0.10.1`
@ import cats._, cats.data._, cats.implicits._, cats.effect._
@ def lift(i: Int): IO[Int] = Timer[IO].sleep(1.second) >> IO {
println(Thread.currentThread.getName + "At time = " + java.time.Instant.now)
i
}
@kevinmeredith
kevinmeredith / logback_disable_in_unit_tests.md
Created May 9, 2018 16:22 — forked from traviskaufman/logback_disable_in_unit_tests.md
Logback: Disable all logging in unit tests

After scouring the internet and piece-mealing together the correct way to do this, here is a step-by-step, all-in-one-place guide to making logback STFU when running your unit tests.

Here's how to do it

Save the following as logback-test.xml under src/test/resources:

<configuration>
  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
      <pattern>%msg%n</pattern>
@kevinmeredith
kevinmeredith / a.scala
Created April 14, 2018 16:40
Circe Enum Example
import $ivy.`com.beachape::enumeratum-circe:1.5.17`
import enumeratum._
sealed trait Color extends EnumEntry; case object Color extends Enum[Color] with CirceEnum[Color] {
case object Red extends Color
case object Green extends Color
case object Blue extends Color
@kevinmeredith
kevinmeredith / a.md
Created November 24, 2017 02:17
Working on examples/exercises of snoyberg/conduit README
$cat app/Main.hs
module Main where

{-# LANGUAGE ExtendedDefaultRules #-}

import Control.Monad.Trans.List
import Conduit
import Control.Applicative
@kevinmeredith
kevinmeredith / a.hs
Created November 1, 2017 13:01
Monad Arrow Notes
import Control.Arrow
import Control.Monad
-- Prelude Control.Monad Control.Arrow> :t (|||)
-- (|||) :: ArrowChoice a => a b d -> a c d -> a (Either b c) d
-- Prelude Control.Monad Control.Arrow> :k ArrowChoice
-- ArrowChoice :: (* -> * -> *) -> Constraint