Skip to content

Instantly share code, notes, and snippets.

View martinlechner1's full-sized avatar

Martin Lechner martinlechner1

View GitHub Profile
@martinlechner1
martinlechner1 / happy_git_on_osx.md
Last active August 29, 2016 12:56 — forked from trey/happy_git_on_osx.md
Creating a Happy Git Environment on OS X

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"

@martinlechner1
martinlechner1 / myfile.elm
Created March 15, 2017 19:46
Some random elm code to process a large list...
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 / fpmaterial.md
Last active January 11, 2019 13:00
FP Material

Scala FP Material

Books

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

Blog Posts

#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";
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()
prestoTransactor().use { xa => queryProgram(xa) }.unsafeRunSync()
def queryProgram(xa: Transactor[IO]) =
sql"""SELECT your_fields FROM your_table"""
.query[YourModel]
.stream
.transact(xa)
.evalMap(d => IO(println(d)))
.compile
.drain
docker system prune -a --volumes
curl cheat.sh/curl
# 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