Skip to content

Instantly share code, notes, and snippets.

View chuwy's full-sized avatar

Anton Parkhomenko chuwy

View GitHub Profile
@chuwy
chuwy / diff_hosted_repo.txt
Created February 12, 2018 09:01
diff -r hosted repo
Only in hosted: com.admo-analytics
Only in hosted: com.adxtracking
Only in hosted: com.angelrush
Only in hosted: com.calltracks
Only in hosted: com.certivox
Only in repo: com.convertro
Only in hosted: com.duproprio
Only in hosted: com.duproprio_comfree
Only in hosted: com.findly
Only in hosted: com.finerylondon
@chuwy
chuwy / BreakReferentialTransparency.scala
Created March 1, 2018 11:48
Interleaving lazy and eager evaluation to break referential transparency
import cats._
import cats.implicits._
import cats.effect._
import cats.effect.implicits._
object Db {
private val cache = collection.mutable.Map.empty[String, String]
def expensiveIO(input: String): IO[String] =
IO { Thread.sleep(1000); println("Executed expensive action"); input ++ input }
@chuwy
chuwy / iglu-violation.json
Created March 18, 2019 13:20
Iglu Client error format
{
"anyOf": [
{
"description": "Resolution error - schema could not be found on specified repositories, defined by ResolutionError ADT in Iglu Client",
"properties": {
"repositories": {
"description": "Defined by LookupHistory ADT in Iglu Client",
"properties": {
"name": {
"type": "string",
object WeirdChunks {
import cats.effect.concurrent.Ref
import fs2.concurrent.Queue
import scala.concurrent.duration._
implicit val t = IO.timer(scala.concurrent.ExecutionContext.global)
implicit val cs = IO.contextShift(scala.concurrent.ExecutionContext.global)
def init: IO[(Ref[IO, Int], Queue[IO, String])] =
/** Always positive integer, nobody can do `new PositiveInt(-3)` */
class PositiveInt private(value: Int) extends AnyVal
/** Set of constructors for PositiveInt */
object PositiveInt {
/** The only proper constructor. Everything else is workaround */
def fromInt(int: Int): Option[PositiveInt] = if (int > 0) Some(new PositiveInt(int)) else None
/**
* This is a workaround and must be called ONLY when caller is sure the `int` is positive
trait Mutability[F[_]] {
def init[A](a: A): F[Mutability.Var[F, A]]
}
object Mutability {
trait Var[F[_], A] {
def get: F[A]
def put(a: A): F[Unit]
}
@chuwy
chuwy / Data.hs
Last active March 16, 2020 11:44
data Option a where
Some : a -> Option a
None : Option a
instance Functor
fmap : (a -> b) -> Option a -> Option b
fmap f (Some a) = Some (f a)
fmap _ None = None
deriving instance Show given Show a
@chuwy
chuwy / extract.sh
Created June 13, 2020 11:04
Extract enrich repositories from snowplow/snowplow monorepo
#!/bin/sh
cp -R ../snowplow .
cd snowplow/
git filter-repo \
--path 3-enrich/scala-common-enrich \
--path 3-enrich/spark-enrich \
--path 3-enrich/beam-enrich \
@chuwy
chuwy / 0001-Unify.patch
Created June 13, 2020 11:06
Combine enrich submodules into a single SBT project
From fe136f1c24a2d3510f654348fa4522f48cdc6efb Mon Sep 17 00:00:00 2001
From: Anton Parkhomenko <mailbox@chuwy.me>
Date: Sat, 13 Jun 2020 14:52:47 +0700
Subject: [PATCH] Unify
---
beam.sbt | 88 ---------
build.sbt | 172 ++++++++++++++++++
common.sbt | 68 -------
...mmonSettings.scala => BuildSettings.scala} | 68 ++++++-
@chuwy
chuwy / README.md
Last active June 17, 2020 15:28
Second version of Iglu root metaschema

Files

  • metaschema.json - new root metaschema to put in $schema properties
  • example-meta.json - example registry metaschema, i.e. one hosted on Acme Ltd. (Mixpanel, Iteratively, Snowplow) Iglu registry and thus specific to all its schemas. Can have 2-0-0 or 1-0-0 root metaschema
  • example-schema.json - plain (non-meta, usual) schema hosting on Acme Ltd. registry and containing metadata described by above metaschema

Changes

Compared to 1-0-0