Skip to content

Instantly share code, notes, and snippets.

View DmytroMitin's full-sized avatar
😎
everything is ok

Dmytro Mitin DmytroMitin

😎
everything is ok
View GitHub Profile
@ashrithr
ashrithr / buildScalaProject.sh
Last active November 18, 2022 08:24
creates scala project structure using sbt 0.13
#!/bin/bash
function usage () {
script=$0
cat <<USAGE
Creates scala project structure to be used with sbt
Syntax
`basename $script` project_name artifact_id
@tstone
tstone / val-vs-lazy-val.scala
Last active November 11, 2022 10:29
val vs. lazy val for implicit class's in Scala
implicit class StringOps(s: String) {
val one = { println("one"); "one" }
val two = { println("two"); "two" }
lazy val three = { println("three"); "value" }
}
scala> "asdf".three
one
@retronym
retronym / indylambda.md
Last active February 5, 2022 10:47
indylambda: Putting invokedynamic to work for Scala

indylambda: Putting invokedynamic to work for Scala

Java 8 introduced lambdas to the Java language. While the design choices differ in many regards from Scala's functions, the underlying mechanics used to represent Java lambdas is flexible enough to be used as a target for the Scala compiler.

Lambdas in Java

Java does not have canonical heirarchy of generic function types (ala scala.FunctionN), but instead allows a lambda to be used as a shorthand for an anonymous implementation of an Functional Interface

Here's an example of creating a predicate that closes over one value:

@vt0r
vt0r / GnuPG-2.2.md
Last active February 13, 2024 09:03 — forked from mattrude/GnuPG-2.1.md
Build/install instructions for GnuPG 2.2.x on Ubuntu and similar distros (formerly for 2.1.x)

GnuPG 2.2.x Build Instructions

Below are my build instructions for GnuPG 2.2.10, released on August 30th, 2018. These instructions are built for a headless Ubuntu 18.04 LTS server (and have also been tested on Ubuntu 14.04/16.04).

If you prefer, you may use the below install script to install GnuPG 2.2.x by running the following commands:

curl -OL "https://gist.githubusercontent.com/vt0r/a2f8c0bcb1400131ff51/raw/e0d2011d7b89bfe5b83c3f29f21949fb21354dd9/install-gnupg22.sh" && sudo -H bash ./install-gnupg22.sh

Install the needed dependencies

@queertypes
queertypes / Teletype.hs
Created April 28, 2016 03:32
This is a tiny example of using Free monads + improve.
{-# LANGUAGE FlexibleContexts, DeriveFunctor #-}
--------------------------------------------------------------------------------
-- It's no secret - Allele Dev enjoys writing Haskell
--
-- This is a tiny example of using Free monads + improve.
--------------------------------------------------------------------------------
module Control.Teletype where
import Control.Monad
import Control.Monad.Free
@OlivierBlanvillain
OlivierBlanvillain / TypeLevelBacktrack.scala
Last active June 6, 2020 23:52
Example of a workaround for the absence of backtracking in implicit resolution. Original problem statement: https://gist.github.com/atamborrino/daa451aea542e912c2d6
import shapeless.{HList, HNil, ::}
import shapeless.ops.hlist.{Selector, Prepend}
import shapeless.test.illTyped
object TypeLevelBacktrack extends App {
/** [[Parent]] / [[Child]] relationship, father side. */
trait FatherOf[Parent, Child]
/** [[Parent]] / [[Child]] relationship, mother side */
trait MotherOf[Parent, Child]
@smarter
smarter / gadt.md
Last active March 6, 2024 23:33
GADTs in Scala

Generalized Algebraic Data Types in Scala

Basic GADTs

Here's an ADT which is not a GADT, in Haskell:

data Expr = IntExpr Int | BoolExpr Bool
@Jasper-M
Jasper-M / HasCompanion.scala
Last active November 2, 2022 02:18
Typeclass that provides evidence that a type has a companion object, and access to the object.
import scala.language.experimental.macros
import scala.reflect.macros.whitebox.Context
trait HasCompanion[A] {
type Type
def companion: Type
}
object HasCompanion {
type Aux[A,C] = HasCompanion[A] { type Type = C }
def apply[A](implicit hc: HasCompanion[A]): hc.type = hc
@claudinei-daitx
claudinei-daitx / SparkSessionKryo.scala
Last active March 22, 2023 15:51
Examples to create a Spark Session with Kryo
import org.apache.spark.SparkConf
import org.apache.spark.sql.SparkSession
//create a spark session who works with Kryo.
object SparkSessionKryo {
def getSparkSession: SparkSession = {
val spark = SparkSession
.builder
.appName("my spark application name")
.config(getConfig)
@AndyShiue
AndyShiue / CuTT.md
Last active June 22, 2024 12:04
Cubical type theory for dummies

I think I’ve figured out most parts of the cubical type theory papers; I’m going to take a shot to explain it informally in the format of Q&As. I prefer using syntax or terminologies that fit better rather than the more standard ones.

Q: What is cubical type theory?

A: It’s a type theory giving homotopy type theory its computational meaning.

Q: What is homotopy type theory then?

A: It’s traditional type theory (which refers to Martin-Löf type theory in this Q&A) augmented with higher inductive types and the univalence axiom.