Skip to content

Instantly share code, notes, and snippets.

@Yyukan
Yyukan / SmartTap.scala
Created March 12, 2019 07:49
The Functional Scala Concurrency Challenge http://degoes.net/articles/zio-challenge
package net
import net.Tap.Percentage
import scalaz.zio.{Ref, UIO, ZIO}
/**
* A `Tap` adjusts the flow of tasks through
* an external service in response to observed
* failures in the service, always trying to
* maximize flow while attempting to meet the
@Yyukan
Yyukan / http4szio.scala
Created March 1, 2019 07:45
Http4s example with ZIO
import cats.effect
import scalaz.zio._
import scalaz.zio.interop.catz._
import org.http4s._
import org.http4s.dsl.io._
import org.http4s.implicits._
import org.http4s.server.Router
import org.http4s.server.blaze.BlazeServerBuilder
import scalaz.zio.clock.Clock
@Yyukan
Yyukan / http4sproxy.scala
Created February 7, 2019 12:49
Forward proxy on http4s
case class ForwardRoute[F[_]](components: Components[F])
(implicit E: Effect[F], L: Logging[F]) extends Routes[F] {
private val http = components.http
private val forward = components.config.forwardTo
def routes: HttpService[F] = HttpService[F] {
case request =>
for {
a <- E.pure(Authority(host = RegName(forward), port = Some(80)))
@Yyukan
Yyukan / SparkDiff.scala
Created April 25, 2018 12:35
Json and CSV file diff using Spark
object Diff extends App {
val jsonInput = "file.json"
val csvInput = "file.csv"
val config: SparkConf = new SparkConf()
.setAppName("Step diff")
.setMaster("local[8]")
val spark = SparkSession
@Yyukan
Yyukan / pom.xml
Created April 24, 2018 06:01
Setup for IT tests in Maven via docker plugin
<profiles>
<profile>
<id>docker</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
@Yyukan
Yyukan / EitherFuture.scala
Created April 18, 2018 07:44
Example of using EitherT monad transformer with Future
import cats.implicits._
import cats.data.EitherT
import scala.concurrent.Future
import scala.concurrent.Await
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
trait ServiceError
case object Timeout extends ServiceError
@Yyukan
Yyukan / JiraSprint-API.scala
Last active July 29, 2017 07:00
JIRA API to retrieve sprint information
package models
import play.api.libs.json._
import play.api.{Logger, Play}
import scala.util.{Try, Failure, Success}
import play.api.libs.json.JsString
import scala.Some
import play.api.libs.json.JsNumber
import play.api.libs.json.JsObject
import play.api.libs.ws.{Response, WS}
/**
* Wires {@link Validate} annotation with rest call to perform validation on the request entity
* ...
* @POST
* ...
* @Validate(RequestValidator.class)
* public Response restCall(TransportModel request)
*
* <aop:aspectj-autoproxy />
*/
@Yyukan
Yyukan / SpringConditionalDemo.java
Last active November 10, 2015 09:49
Spring 4 Conditional simple example
package net.oshtykhno.spring;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.context.annotation.Conditional;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.stereotype.Component;