Skip to content

Instantly share code, notes, and snippets.

View chuwy's full-sized avatar

Anton Parkhomenko chuwy

View GitHub Profile
@chuwy
chuwy / unsound.roc
Last active October 28, 2024 18:26
Foo : [Foo I8]
Bar : [Bar U8]
Reader a : (a -> Str)
flatMap : Reader a, (a -> Reader b) -> Reader b
flatMap = crash "implement flatMap"
foo : Reader Foo
foo = crash "implement Reader Foo"
@chuwy
chuwy / shell.nix
Last active September 29, 2024 14:53
django-unicorn dev environment
{ pkgs ? import <nixpkgs> {} }:
let
deps = [
pkgs.python3Packages.beautifulsoup4
pkgs.python3Packages.cachetools
pkgs.python3Packages.decorator
pkgs.python3Packages.django
pkgs.python3Packages.orjson
pkgs.python3Packages.shortuuid
@chuwy
chuwy / shell.nix
Created September 29, 2024 14:31
poetry2nix install instructions
{ pkgs ? import <nixpkgs> {} }:
let
python = pkgs.python3;
poetry2nix = pkgs.stdenv.mkDerivation rec {
name = "poetry2nix";
src = pkgs.fetchFromGitHub {
owner = "nix-community";
@chuwy
chuwy / AllSubtypesOf.scala
Created April 1, 2024 06:59
A Scala 3 match type that checks that all elements of a tuple match a certain (sub)type
import scala.compiletime.ops.boolean.&&
type AllSubtypesOfMatch[T <: Tuple, Super] <: Boolean = T match
case EmptyTuple =>
true
case h *: t =>
h match
case Super => AllSubtypesOfMatch[t, Super]
type AllSubtypesOf[T <: Tuple, Super] = AllSubtypesOfMatch[T, Super] =:= true
@chuwy
chuwy / README.md
Created August 12, 2023 11:36 — forked from runiq/README.md
Neovim throttle & debounce

What are these?

Functions that allow you to call a function not more than once in a given timeframe.

Throttling on the leading edge

This can be illustrated with timing diagrams. In the following diagrams, f designates call to the throttled function, t is the period where the timer is running, and x shows you the actual execution point of the throttled function.

f 1  2  3  4  5  6
@chuwy
chuwy / ConfigWithComments.scala
Created August 11, 2023 10:06 — forked from DiggesT/Api.scala
Scala code research
def loadFromPath[F[_]: Sync](path: JPath): F[Config] =
val source = ConfigSource.default(ConfigSource.file(path)).withFallback(ConfigSource.default)
loadF[F, Config](source)
def load(args: List[String]): IO[Either[Help, (SubCommand, Option[Config])]] = //input array: List[String], output: why IO
command.parse(args) match // how it matching string with help/commands?
case Left(help) => IO.pure(help.asLeft) //help command
case Right(cli) => //other commands
cli match //match with SubCommand
case SubCommand.Run(configPath, _) => //Run command
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 August 22, 2023 19:54
Scala macro for building type-safe SQL Fragments
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
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(
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)