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
use std::collections::VecDeque; | |
use std::fmt::{Display}; | |
#[derive(Clone, Debug, PartialEq)] | |
pub enum InferredType { | |
U8, | |
U16, | |
Record(Vec<(String, InferredType)>), | |
AllOf(Vec<InferredType>), | |
} |
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
use std::collections::BTreeMap; | |
use std::fmt::Debug; | |
use std::cmp::PartialOrd; | |
use crate::internal_types::AI; | |
trait Conversion: Debug + Clone { | |
type WitType: Clone + Debug; | |
fn from_wit_type(input: Self::WitType) -> Result<Self, String>; | |
fn to_wit_type(&self) -> Result<Self::WitType, String>; |
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
sealed trait Tree | |
case class Bin(x: Tree, y: Tree) extends Tree | |
case class Lt(in: Int) extends Tree | |
/** | |
* Infinite recursion - duplicate all binary values | |
*/ | |
def topddown_duplicate_bins(tree: Tree): Tree = tree match { | |
case Bin(x, y) => |
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 metrics | |
import java.sql.ResultSet | |
/** | |
* A highly simplified functional jdbc with no dependencies. | |
* Serves the purpose for the time being. Currently returns scala.Stream. | |
*/ | |
object myjdbc { | |
trait Primitive[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
trait OptionSyntax { | |
implicit class OptionOps[A](s: Option[A]) { | |
def ifExists[F[_], B](f: A => F[B]): PartialOption[F, B] = | |
s match { | |
case Some(value) => new PartialOption(Some(f(value))) | |
case None => new PartialOption(None) | |
} | |
} | |
} |
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 com..s3paths | |
import cats.free.Cofree | |
import com.s3paths.nonfree.Component.Version | |
import com.s3paths.nonfree.Component.RunTime | |
import com.s3paths.nonfree.Component.Adhoc | |
import cats.Traverse | |
import cats.Eval | |
// Well we need name and pos | |
import cats.Id |
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
// MANAGING/COMBINING MULTIPLE SOURCES, DIFFERENT KEYS IN EACH SOURCES etc IN ZIO-CONFIG | |
// .. A follow up on the questions during FS2020 | |
final case class Config(username: String, age: Int) | |
// Same as val configSpec = magnolia.descriptor[Config] | |
val configSpec: ConfigDescriptor[Config] = | |
(string("username") |@| int("age"))(Config.apply, Config.unapply) | |
val configPgm1: ConfigDescriptor[Config] = |
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 zio.config.examples | |
import java.lang.{ Boolean => JBoolean } | |
import scala.util.{ Failure, Success, Try } | |
import com.typesafe.config._ | |
import zio.config.typesafe._ | |
import zio.{ IO } | |
import zio.config._, ConfigDescriptor._ | |
/** |
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 java.io.FileInputStream | |
import java.nio.file.{ Files, Path } | |
import cats.Applicative | |
import cats.implicits._ | |
import cats.effect.{ IO, Resource } | |
import com.amazonaws.services.s3.model.S3Object | |
import org.apache.commons.codec.digest.DigestUtils | |
import org.apache.commons.io.FileUtils |
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 cats.effect.{ IO, Resource } | |
import com.amazonaws.services.s3.AmazonS3 | |
import com.amazonaws.services.s3.model.ListObjectsV2Request | |
import org.apache.commons.lang.StringUtils | |
def getKeys(client: AmazonS3, path: S3Path): IO[List[String]] = IO { | |
client | |
.listObjectsV2( | |
new ListObjectsV2Request().withBucketName(path.parentBucket).withPrefix(path.prefix) | |
) |
NewerOlder