Skip to content

Instantly share code, notes, and snippets.

@fancellu
fancellu / ExceptionDig.scala
Last active December 13, 2023 06:07
Various ways to recurse down Exception causes in Scala
// Using vars, lots of local mutation
def getThemVar(th:Throwable)={
var now=th
var li=List[Throwable](now)
var cause=now.getCause
while (cause!=null){
li=cause::li
now=cause
cause=now.getCause
}
@bijanebrahimi
bijanebrahimi / i3-config
Last active October 7, 2018 14:53
Run terminator as a drop-down tiling terminal in i3-wm using scratchpad
# Add this to your i3 config (~/.config/i3/config) and restart i3 (Super+Shift+R)
exec --no-startup-id "terminator -m"
for_window [class="Terminator" title="^((?!Terminator Preferences).)*$"] move scratchpad, move position 0 0, resize set 1366 768;
bindsym F1 [class="Terminator"] scratchpad show;

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@mandubian
mandubian / kind_polymorphic.scala
Last active November 28, 2016 20:33
PoC for Kind Polymorphism in Scala
// That compiles for real in a patched version of Scala just introducing the KindPolymorphic syntax
object Test {
// Basic Kind polymorphism sample
trait Foo[T <: KindPolymorphic] { type Out ; def id(t: Out): Out = t }
object Foo {
implicit def foo0[T] = new Foo[T] { type Out = T }
implicit def foo1[T[_]] = new Foo[T] { type Out = T[Any] }
implicit def foo2[T[_, _]] = new Foo[T] { type Out = T[Any, Any] }
}
@chadselph
chadselph / AkkaHttpHeaderExtractor.scala
Last active July 3, 2022 16:04
akka-http directive for opentracing.io
import java.util
import java.util.Map.Entry
import akka.http.scaladsl.model.HttpHeader
import io.opentracing.propagation.TextMap
import scala.collection.JavaConverters.asJavaIteratorConverter
/**
* Used to extract an iterator of Entry[String, String] to the