Skip to content

Instantly share code, notes, and snippets.

View MateuszKubuszok's full-sized avatar
🏠
Vacationing from OSS at an actual work

Mateusz Kubuszok MateuszKubuszok

🏠
Vacationing from OSS at an actual work
View GitHub Profile
@MateuszKubuszok
MateuszKubuszok / circe-inmemory-ttfi-di.sc
Last active May 8, 2019 13:24
Showoff code that I probably wouldn't use on production, but looks smarter than whatever stuff is actually required in our everyday coding :P
//
// @author: Mateusz Kubuszok
//
// requirements: ammonite 1.1.0
// usage: run `amm` and copy paste into REPL
import $ivy.`org.typelevel::cats-core:1.3.1`, cats._, cats.syntax.all._
import $ivy.`org.typelevel::cats-effect:1.0.0`, cats.effect._, cats.effect.syntax._
import $ivy.`io.circe::circe-core:0.9.3`, io.circe._, io.circe.syntax._
import $ivy.`io.circe::circe-generic:0.9.3`, io.circe.generic.auto._
@MateuszKubuszok
MateuszKubuszok / Uncurry.scala
Created March 14, 2020 14:57
Sometimes I missed .uncurried cuntionality in Scala
trait Uncurry[C, U] {
def uncurried(curried: C): U
}
object Uncurry {
def instance[C, U](body: C => U) = new Uncurry[C, U] {
def uncurried(curried: C): U = body(curried)
}
implicit def uncurry2[A, B, Out]: Uncurry[A => B => Out, (A, B) => Out] =
instance[A => B => Out, (A, B) => Out] { curried => curried(_)(_) }
implicit def uncurry3[A, B, C, Out]: Uncurry[A => B => C => Out, (A, B, C) => Out] =
Compiled from "Test1.scala"
public final class Test1$ {
public static final Test1$ MODULE$;
public static {};
Code:
0: new #2 // class Test1$
3: dup
4: invokespecial #18 // Method "<init>":()V
7: putstatic #20 // Field MODULE$:LTest1$;
Compiled from "Test2.scala"
public final class Test2$ {
public static final Test2$ MODULE$;
public static {};
Code:
0: new #2 // class Test2$
3: dup
4: invokespecial #20 // Method "<init>":()V
7: putstatic #22 // Field MODULE$:LTest2$;
@MateuszKubuszok
MateuszKubuszok / .dotsync.yml
Last active August 13, 2020 13:23
Utility for copying dotfiles from HOME to some backup directory e.g. git/Dropbox/etc
backup: .dotsync_bck
global:
include:
- .bashrc
- .zshrc
exclude: []
local:
laptop2:
include:
- .snxrc
@MateuszKubuszok
MateuszKubuszok / flame-graph-cpu-reverse.svg
Created August 31, 2020 13:26
Flame graphs for FizzBuzzBenchmark - Things that you need to know about JVM (that matter in Scala)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MateuszKubuszok
MateuszKubuszok / keybase.md
Created October 12, 2020 10:45
keybase.md

Keybase proof

I hereby claim:

  • I am mateuszkubuszok on github.
  • I am mateuszkubuszok (https://keybase.io/mateuszkubuszok) on keybase.
  • I have a public key ASDad2uAPXJRFF-i7B7nKeQixgIFu5bVsXJLqD7jJGRg0Ao

To claim this, I am signing this object:

@MateuszKubuszok
MateuszKubuszok / FList.scala
Created October 27, 2020 16:06
List of Functions
sealed trait FList[F[_]] extends Product with Serializable
object FList {
final case class Last[F[_], A, B](f: A => F[B]) extends FList[F]
final case class Cons[F[_], A, B, Tail <: FList[F]](f: A => F[B], tail: Tail) extends FList[F]
}
implicit class FunOps[F[_], A, B](f: A => F[B]) extends AnyVal {
def toFList: FList.One[F, A, B] = FList.One(f)
@MateuszKubuszok
MateuszKubuszok / algebras.scala
Last active March 2, 2021 14:34
Algebras implementation which isn't based on nested type hierarchy
import scala.language.reflectiveCalls
type Nullary[A] = Unit
type Unary[A] = A
type Binary[A] = (A, A)
trait Algebra {
type Set
type Operation[F[_]] = F[Set] => Set
@MateuszKubuszok
MateuszKubuszok / TypedSliding.scala
Created March 15, 2021 16:03
Safe sliding in Scala
trait TypedSlide[F[_], I <: Int] {
type Out[A]
def sliding[A](fa: F[A]): F[Out[A]]
}
object TypedSlide {
type Arbitrary
class Helper[F[_], I <: Int] {
def apply[OOut[_]](f: F[Arbitrary] => F[OOut[Arbitrary]]) = new TypedSlide[F, I] {
type Out[A] = OOut[A]