Skip to content

Instantly share code, notes, and snippets.

Avatar

Martin Lechner martinlechner1

View GitHub Profile
View ZIO
# 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
View useful-commands.sh
docker system prune -a --volumes
curl cheat.sh/curl
View sqlProgram.scala
def queryProgram(xa: Transactor[IO]) =
sql"""SELECT your_fields FROM your_table"""
.query[YourModel]
.stream
.transact(xa)
.evalMap(d => IO(println(d)))
.compile
.drain
View transactorUse.scala
prestoTransactor().use { xa => queryProgram(xa) }.unsafeRunSync()
View buildTransactor.scala
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()
View Sensor.ino
#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";
View fpmaterial.md

Scala FP Material

Books

  • Redbook
  • Advanced Scala with Cats
  • Functional Programming for Mortals

Blog Posts

@martinlechner1
martinlechner1 / myfile.elm
Created Mar 15, 2017
Some random elm code to process a large list...
View myfile.elm
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
@martinlechner1
martinlechner1 / happy_git_on_osx.md
Last active Aug 29, 2016 — forked from trey/happy_git_on_osx.md
Creating a Happy Git Environment on OS X
View happy_git_on_osx.md

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
You can’t perform that action at this time.