Skip to content

Instantly share code, notes, and snippets.

View abelbryo's full-sized avatar

Abel Terefe abelbryo

View GitHub Profile
@matfournier
matfournier / RepeatEval.scala
Last active October 6, 2022 08:36
forever repeating an action cats-effect question
/** An effect for infinitely repeating an action, use with care
* as there is no way to kill the process w/o shutting down the
* server in this implementation */
trait RepeatEval[F[_]] {
def repeat[A](fa: F[A], duration: FiniteDuration): F[Unit]
}
object RepeatEval {
def apply[F[_]](implicit ev: RepeatEval[F]): RepeatEval[F] = ev
@blagerweij
blagerweij / S3OutputStream.java
Created October 23, 2020 22:40
OutputStream which wraps S3Client, with support for streaming large files directly to S3
import java.io.ByteArrayInputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest;
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest;
import com.amazonaws.services.s3.model.InitiateMultipartUploadRequest;
package sillio
import cats.syntax.all._
import scala.annotation.tailrec
import scala.concurrent.ExecutionContext
import scala.util.control.NonFatal
import java.util.concurrent.atomic.{AtomicBoolean, AtomicReference}
@carlosedp
carlosedp / httpserver.scala
Last active March 20, 2024 00:57
Scala ZIO-HTTP with logback and GraalVM native-image binary support
// Run with scala-cli httpserver.scala
// Save logback.xml file into ./resources dir
// Before generating native image binary, run first as above and make a real access to the URL
// so the native-image-agent can generate the metadata in ./resources dir.
// Then generate native image binary with: scala-cli package --native-image httpserver.scala
//> using scala "3.3.0"
//> using lib "dev.zio::zio:2.0.15"
//> using lib "dev.zio::zio-http:3.0.0-RC2"
//> using lib "dev.zio::zio-logging-slf4j2::2.1.13"
//> using lib "ch.qos.logback:logback-classic:1.4.8"