Skip to content

Instantly share code, notes, and snippets.

Avatar

Anton Parkhomenko chuwy

View GitHub Profile
View Span.scala
type SpanF[A, C] <: Tuple = (A, C) match
case ((as, bs), (a, b)) => (as *: a, bs *: b)
type Span[A <: Tuple] = Fold[A, (EmptyTuple, EmptyTuple), SpanF]
def span[T <: Tuple](t: Tuple): Option[Span[T]] =
def go[TT <: Tuple, A <: Tuple, B <: Tuple](remaining: TT, as: A, bs: B): Option[(A, B)] =
remaining match
case EmptyTuple => Some((as, bs))
case (a, b) *: tt => go(tt, a *: as, b *: bs).asInstanceOf[Option[(A, B)]]
@chuwy
chuwy / Table.scala
Last active March 14, 2023 18:06
Scala macro for building type-safe SQL Fragments
View Table.scala
import java.time.LocalDateTime
import scala.quoted.*
import scala.deriving.Mirror
import quotidian.*
import quotidian.syntax.*
import io.github.iltotore.iron.*
@chuwy
chuwy / run_shredder.py
Created January 10, 2022 15:26
No Dataflow Runner
View run_shredder.py
import boto3
connection = boto3.client(
'emr',
region_name='eu-central-1',
aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_KEY,
)
cluster_id = connection.run_job_flow(
View topology.scala
def input[F[_]: Timer] =
(Stream(1, 2, -3, 4, -5) ++
Stream.sleep_(1.second) ++
Stream(4, 3, -1, -2, 1) ++
Stream.sleep_(1.second) ++
Stream(0, 2, -5) ++
Stream.sleep_(1.second) ++
Stream(-6, 1, 2, 0, -1, -4, 2, 9)
).covary[F].map(i => if (i % 2 == 0) i.asRight else (i.toString + "b").asLeft)
View test-pg-loader.sh
#!/bin/sh
set -e
if [ -z ${TRAVIS_BUILD_DIR+x} ]; then
echo "TRAVIS_BUILD_DIR is unset";
exit 1
fi
IGLUCTL_ZIP="igluctl_0.6.0.zip"
@chuwy
chuwy / README.md
Last active June 17, 2020 15:28
Second version of Iglu root metaschema
View README.md

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

@chuwy
chuwy / 0001-Unify.patch
Created June 13, 2020 11:06
Combine enrich submodules into a single SBT project
View 0001-Unify.patch
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 / extract.sh
Created June 13, 2020 11:04
Extract enrich repositories from snowplow/snowplow monorepo
View extract.sh
#!/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 / Data.hs
Last active March 16, 2020 11:44
View Data.hs
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
View gist:1854efe7a70a7344f22c102a39266113
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]
}