Skip to content

Instantly share code, notes, and snippets.

View matfournier's full-sized avatar

matfournier matfournier

View GitHub Profile
@matfournier
matfournier / notes.md
Created April 3, 2020 04:14
scaladoc in doom emacs
@matfournier
matfournier / ex.scala
Created March 29, 2020 23:23
Wrapping legacy blocking / context shift / blocker
trait Statsd[F[_]] {
def inc(key: String, magnitude: Int = 1, sampleRate: Double = 1.0): F[Unit]
def dec(key: String, magnitude: Int = 1, sampleRate: Double = 1.0): F[Unit]
def gauge(key: String, magnitude: Double, sampleRate: Double = 1.0): F[Unit]
def timer(key: String, value: Int, sampleRate: Double = 1.0): F[Unit]
}
object Statsd {
def apply[F[_]](implicit F: Statsd[F]): Statsd[F] = F
}
@matfournier
matfournier / ex.scala
Last active March 29, 2020 22:41
Legacy Context Shfit Example
trait Statsd[F[_]] {
def inc(key: String, magnitude: Int = 1, sampleRate: Double = 1.0): F[Unit]
def dec(key: String, magnitude: Int = 1, sampleRate: Double = 1.0): F[Unit]
def gauge(key: String, magnitude: Double, sampleRate: Double = 1.0): F[Unit]
def timer(key: String, value: Int, sampleRate: Double = 1.0): F[Unit]
}
// the legacy client takes in a fixed thread pool of 1. Under the hood it does some
// websocket / NIO stuff
// am I wrong to contextShift onto the same thread pool that it's using?
@matfournier
matfournier / crawl.rc
Created March 2, 2020 06:18
crawl.rc
##### Crawl Init file ###############################################
# For descriptions of all options, as well as some more in-depth information
# on setting them, consult the file
# options_guide.txt
# in your /docs directory. If you can't find it, the file is also available
# online at:
# https://github.com/crawl/crawl/blob/master/crawl-ref/docs/options_guide.txt
#
# Crawl uses the first file of the following list as its option file:
# * init.txt in the -rcdir directory (if specified)
@matfournier
matfournier / blah.el
Created January 14, 2020 18:44
emacs scala lsp
(map! :map scala-mode-map
"C-c C-t" #'lsp-ui-doc-show ;; shows type under cursor as a hover
"C-c t" #'lsp-describe-thing-at-point ;; shows type under cursor in temp buffer below
"C-c H" #'lsp-ui-doc-mode ;; toggle auto-showing type under cursor asa hover
"C-c F" #'lsp-format-buffer ;; run scalafmt on the entire buffer
"C-c f" #'lsp-format-region ;; run scalafmt on the selected region
"C-c C-f" #'lsp-find-references ;; find references symbol under cursor
"C-c i" #'lsp-execute-code-action ;; import missing type/class
"C-c r" #'lsp-rename ;; rename symbol
"C-c e" #'lsp-ui-flycheck-list ;; list all errors
@matfournier
matfournier / stupid.hs
Created December 26, 2019 06:08
stupid adt example
module Scratch where
data Shape = Circle { radius :: Int }
| Rectangle {length :: Int, width :: Int}
| Triangle {length :: Int, height :: Int}
deriving (Show, Eq)
-- how would you fromJSON shape assuming there
@matfournier
matfournier / example.hs
Last active December 26, 2019 04:03
conduit json parsing
avgForClient :: Purchase -> Double
avgForClient (Purchase _ products) =
let n = fromIntegral $ DT.length products
totals = sum $ price <$> products
in totals / n
-- outputs nullnullnullnull... unless the json is on a single line.
-- how to make this work for multi-line json?
main :: IO ()
@matfournier
matfournier / zioEnv.scala
Created December 15, 2019 01:21
zioEnv help
// a NoOpLogger of zio-logging for a logging effect
trait NoOpLogger extends Logging[String] {
def logging: Logging.Service[Any, String] = new Logging.Service[Any, String] {
override def trace(message: => String): ZIO[Any, Nothing, Unit] = ZIO.unit
override def debug(message: => String): ZIO[Any, Nothing, Unit] = ZIO.unit
override def info(message: => String): ZIO[Any, Nothing, Unit] = ZIO.unit
override def warning(message: => String): ZIO[Any, Nothing, Unit] = ZIO.unit
@matfournier
matfournier / books.md
Last active December 10, 2019 17:04
cookbooks

I cook tons. I have ~100 cookbooks, a 1HP meat grinder, a deep fryer, a 75,000 BTU outdoor wok, a mangal, many fermenting vessels, hell a fermenting chamber for koji, and way too many knives. Someone at work asked about cookbook recommendations by country so here it is. There are many omissions to this list. It aims to be "if I wanted to get into X cuisine, what is the first cookbook I should buy to get started'.

Cookbooks

General italian - Zuni cafe cookbook is a standout. Everyone says to get a copy of Marcella Hazen's Essential Italian but meh, I reach to zuni cafe way more often. Hightly recommended. Maybe Molto Mario or Babbo for a second or third italian book, but get zuni cafe first.

just pasta: flour + water

thai: the first pok pok cookbook is great (not the drinking food of thailand, not pok pok noodles) and super easy to get into. If that hooks you, Thai Food by Thompson is the bible, but muc harder to approach. Night+Market is also a good second book. (edited)

@matfournier
matfournier / example.scala
Last active December 3, 2019 22:34
RefinedCustomValidation
// the type I take in which isn't that useful
case class AuthorizeRequest(
code: Option[String],
token: Option[String],
secret: Option[String],
verifier: Option[String],
redirectUri: String,
clientId: String,
clientSecret: String
)