- Redbook
- Advanced Scala with Cats
- Functional Programming for Mortals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ZIO usage | |
## ZLayer for dependency management | |
- Type safe | |
- Composable | |
- No Magic / No reflection (unlike Guice) | |
- Support for modeling failing dependencies (such as config loading) | |
## Module pattern |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker system prune -a --volumes | |
curl cheat.sh/curl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def queryProgram(xa: Transactor[IO]) = | |
sql"""SELECT your_fields FROM your_table""" | |
.query[YourModel] | |
.stream | |
.transact(xa) | |
.evalMap(d => IO(println(d))) | |
.compile | |
.drain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prestoTransactor().use { xa => queryProgram(xa) }.unsafeRunSync() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private def buildTransactor(c: Connection): Resource[IO, Transactor[IO]] = | |
Blocker[IO].map { b => | |
Transactor.fromConnection[IO](c, b) | |
} | |
private def prestoTransactor(): Resource[IO, Transactor[IO]] = | |
Resource.fromAutoCloseable[IO, Connection] { | |
IO.fromTry(Try { | |
val url = "jdbc:presto://your-presto-jdbc-url" | |
val properties = new Properties() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ESP8266WiFi.h> | |
#include <PubSubClient.h> | |
#include <Adafruit_Sensor.h> | |
#include <Adafruit_BME280.h> | |
#include <ArduinoJson.h> | |
const char* SSID = "ssid"; | |
const char* PSK = "wifi key"; | |
const char* MQTT_BROKER = "mqtt ip"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
convertRecordsTask : Task Http.Error (List (List String)) -> Task Http.Error (List TrajectoryPoint) | |
convertRecordsTask task = | |
Task.map convertRecords task | |
convertRecords : List (List String) -> List TrajectoryPoint | |
convertRecords records = | |
List.take 10000 records | |
|> List.map convertRecord |
brew install git bash-completion
Configure things:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"