Skip to content

Instantly share code, notes, and snippets.

Avatar

John A. De Goes jdegoes

View GitHub Profile
View Cron.scala
package zio.cron
import java.time.{ Month => JMonth }
import java.time.{ DayOfWeek => JDayOfWeek }
import zio.Schedule
// 0 16 1,15 * * echo Timesheets Due > /dev/console
final case class CronSchedule(
minute: CronSchedule.Minute,
View CCC.scala
package zio.prelude
trait FunctionBoth[:=>[-_, +_]] extends IdentityCompose[:=>] {
def both[A, B, C, D](f: A :=> B, g: C :=> D): (A, C) :=> (B, D)
def toRightBoth[A]: (Unit, A) :=> A
def toLeftBoth[A]: (A, Unit) :=> A
def lassocBoth[A, B, C]: (A, (B, C)) :=> ((A, B), C)
def rassocBoth[A, B, C]: ((A, B), C) :=> (A, (B, C))
View connect.scala
package zio.connect
import zio._
import zio.stream._
trait S3Connector {
// Powered by ZIO S3
type S3Connector
type S3Credentials
type S3Exception
View Cron.scala
package zio.cron
import java.time.Instant
final case class Cron(moh: Option[MinuteOfHour], hod: Option[HourOfDay], dom: Option[DayOfMonth], moy: Option[MonthOfYear], dow: Option[DayOfWeek]) {
/**
* Returns a `Cron` that describes execution only when both this `Cron` and
* the specified `Cron` would run.
*/
View DynamoDB.scala
package zio.dynamodb
import java.io.IOException
import zio.{ Chunk, Task, ZLayer }
import zio.blocking.Blocking
/*
~~GetItem~~
WriteItem
@jdegoes
jdegoes / http4k.ks
Created Apr 23, 2020
Adding multipart responses into http4k
View http4k.ks
// RFC: https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html
interface Response {
fun multipartBoundary(boundary: String): Response
fun multiparts(): List<Response>
//
// The returned Response will use a content type of multipart response with
// a boundary string determined by the implementation.
//
@jdegoes
jdegoes / ZMX.scala
Created Apr 10, 2020
ZMX Design Sketch
View ZMX.scala
package zio
import zio.duration.Duration
package object zmx extends MetricsDataModel with MetricsConfigDataModel {
type Diagnostics = Has[Diagnostics.Service]
object Diagnostics {
trait Service {
@jdegoes
jdegoes / ZIO-1.0.0-RC-migration.md
Created Mar 4, 2020
Migration notes for ZIO-1.0.0-RC18
View ZIO-1.0.0-RC-migration.md

ZIO's last release candidate before 1.0 (RC18) has arrived!

The first question every user needs to ask themselves:

  • Should they upgrade now?
  • Should they wait for ZIO 1.0?

We need some adventurous souls to upgrade now, because the feedback so generated will help convince us we're ready to pull the trigger on ZIO 1.0 in a couple weeks time.

On the other hand, upgrading now is going to be more difficult, because not all ZIO libraries have been updated to RC18 (we are early in that process), and there is very poor documentation.

@jdegoes
jdegoes / zio-workshops.md
Last active Dec 29, 2019
Possible ZIO Workshops
View zio-workshops.md
  • Scheduling & Retrying with ZIO: A 2 hour workshop that shows how to create and use schedules and retry policies with ZIO. Scheduling covers cache use cases, downloading resources, sending emails; retrying covers flaky web APIs, database connections, etc.
  • ZIO CRUD. A 2 hour workshop showing how to build a basic REST API using ZIO + third-party library.
  • Using ZIO with Legacy Code: A 2 hour workshop that shows how to wrap lots of legacy code: sync code, async code, Future code; and demonstrate use of Runtime to unsafeRun at boundary points for roundtrip integration.
  • Crash Course in ZIO: A 2 hour workshop that covers “hello world” and a few other simple examples of writing programs with ZIO, with an emphasis on thinking functionality (values & operators on values) and using ‘for’ comprehensions successfully.
  • Rethinking Error Management: A 2 hour workshop that shows how to effectively use recoverable and non-recoverable errors, as well as lossless errors, to build resilient apps that
View gadts-session1.scala
package net.degoes.zio
trait Sql {
type ColumnName
type TableName
sealed trait Table[+A]
/**
* (SELECT *, "foo", table.a + table.b AS sum... FROM table WHERE cond) UNION (SELECT ... FROM table)
You can’t perform that action at this time.