This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val ss: SparkSession | |
| val df: DataFrame | |
| import ss.implicits._ | |
| trait NotTypeColumn[C] | |
| object NotTypeColumn { | |
| implicit def notc[C <: org.apache.spark.sql.Column]:NotTypeColumn[C] = new NotTypeColumn[C] {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package io.univalence | |
| import io.univalence.Fk.Encoder.{BindedTypedExprEncoder, SimpleEncoder} | |
| import io.univalence.Fk.Expr.Ops | |
| import io.univalence.Fk.TypedExpr.TypedOr | |
| import org.json4s.JsonAST.{JArray, JString, JValue} | |
| import scala.language.{dynamics, implicitConversions} | |
| object Fk { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def day1(input:Seq[Int]): (Int, Int) = { | |
| val part1 = 0 + input.sum | |
| val part2 = { | |
| val freq: Seq[Int] = Stream.continually(input).flatten | |
| val states: Seq[Int] = freq.scanLeft(0)(_ + _) | |
| val find: Either[Int, Set[Int]] = foldLeftUntil(states)(Set.empty[Int])( | |
| (set, a) => if (set(a)) Left(a) else Right(set + a)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package testMacWire | |
| import com.softwaremill.macwire._ | |
| class DatabaseAccess() | |
| class SecurityFilter() | |
| class UserFinder(databaseAccess: DatabaseAccess, securityFilter: SecurityFilter) | |
| class UserStatusReader(userFinder: UserFinder) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package utils | |
| import org.scalatest.FunSuite | |
| import scalaz.zio.{IO, RTS, Ref} | |
| import utils.CircuitBreaker.{Closed, Open, Status} | |
| final class CircuitBreaker[+BreakingFailure](ref: Ref[CircuitBreakerStatus], | |
| initStatus: CircuitBreakerStatus, | |
| whenOpen: IO[BreakingFailure, Nothing]) { | |
| def protect[E >: BreakingFailure, A](io: IO[E, A]): IO[E, A] = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package io.univalence | |
| import fr.jetoile.hadoopunit.HadoopUtils | |
| import org.apache.spark.sql.SparkSession | |
| object TestSpark { | |
| def main(args: Array[String]): Unit = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.apache.spark.sql | |
| import org.apache.spark.sql.catalyst.InternalRow | |
| import org.apache.spark.sql.catalyst.encoders.{ExpressionEncoder, RowEncoder} | |
| import org.apache.spark.sql.catalyst.expressions.{GenericRow, GenericRowWithSchema} | |
| import org.apache.spark.sql.catalyst.json.{JSONOptions, JacksonParser} | |
| import org.apache.spark.sql.catalyst.util.GenericArrayData | |
| import org.apache.spark.sql.types._ | |
| import org.apache.spark.unsafe.types.UTF8String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object Bowling { | |
| type Coef = (Int, Int) | |
| implicit class Tuple2Ops[A, B](val t: (A, B)) extends AnyVal { | |
| def map_1[C](f: A => C): (C, B) = (f(t._1), t._2) | |
| def map_2[C](f: B => C): (A, C) = (t._1, f(t._2)) | |
| } | |
| case class TempScore(scoreTotal: Int, coef: Coef, isNewTurn: Boolean, nbTurn: Int, lastShot: Option[Int]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import estrapade.{TestApp, test} | |
| import magnolia.{Param, _} | |
| import magnolia.tests.{Destination, Item, OffRoad, Path} | |
| import scala.language.experimental.macros | |
| case class Prefix(names:Seq[String]) { | |
| def add(name:String): Prefix = this.copy(names :+ name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import estrapade.{TestApp, test} | |
| import magnolia._ | |
| import magnolia.tests.{Destination, Item, OffRoad, Path} | |
| import scala.language.experimental.macros | |
| sealed trait TC[A] { | |
| def mapWithPrefix(prefix: String, value: A): Map[String, String] = { | |
| this match { |