Skip to content

Instantly share code, notes, and snippets.

View mattkohl's full-sized avatar
🌀
. . .

Matt Kohl mattkohl

🌀
. . .
View GitHub Profile
@mattkohl
mattkohl / .block
Last active June 12, 2016 14:37
Force-Directed Graph with outwardly floating Node Labels
license: gpl-3.0
@mattkohl
mattkohl / .block
Last active March 26, 2024 18:26
Force-Directed Graph with Multiple Labelled Edges between Nodes
license: gpl-3.0
@mattkohl
mattkohl / .block
Last active June 12, 2016 14:02
Force-Directed Graph with Reflexive Edges
license: gpl-3.0
@mattkohl
mattkohl / .block
Last active June 10, 2016 09:54
Animated Donut Chart with Percentage
license: gpl-3.0

Advanced Functional Programming with Scala - Notes

Copyright © 2017 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
assemblyMergeStrategy in assembly := {
case x if Assembly.isConfigFile(x) =>
MergeStrategy.concat
case PathList(ps @ _*) if Assembly.isReadme(ps.last) || Assembly.isLicenseFile(ps.last) =>
MergeStrategy.rename
case PathList("META-INF", xs @ _*) =>
xs map {_.toLowerCase} match {
case ("manifest.mf" :: Nil) | ("index.list" :: Nil) | ("dependencies" :: Nil) =>
MergeStrategy.discard
case ps @ (x :: xs) if ps.last.equals("pom.properties") || ps.last.equals("pom.xml") =>
@mattkohl
mattkohl / logging_example.py
Created February 10, 2017 12:04
Python logging recipe
import logging
logger = logging.getLogger()
handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
logger.debug("Testing, testing, 1, 2, 3")
docker stats $(docker ps --format={{.Names}})
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case _ => MergeStrategy.first
}
@mattkohl
mattkohl / fp_echo.py
Last active April 3, 2017 13:09
FP version of "echo()"
def identity_print(x):
print(x)
return x
echo_FP = lambda: identity_print(input("FP -- "))=='quit' or echo_FP()
echo_FP()