Skip to content

Instantly share code, notes, and snippets.

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

Matt Kohl mattkohl

🌀
. . .
View GitHub Profile
@mattkohl
mattkohl / update-slack-status-from-spotify.sh
Created March 12, 2018 13:04 — forked from kfox/update-slack-status-from-spotify.sh
Updates your Slack status with the current artist and song title in Spotify
#!/usr/bin/env bash
: "${SLACK_API_TOKEN:?Need to set SLACK_API_TOKEN environment variable}"
STATUS=$(/usr/bin/osascript <<"EOF"
if application "Spotify" is running and application "Slack" is running then
tell application "Spotify"
set currentArtist to artist of current track as string
set currentSong to name of current track as string
return currentArtist & " - " & currentSong
@mattkohl
mattkohl / readme.md
Created August 14, 2017 09:03 — forked from shaun-stripe/readme.md
texas flag emoji for Slack
@mattkohl
mattkohl / instance_to_dict.py
Created June 5, 2017 11:19
Overloading __iter__
class MyClass:
def __init__(self, a, b, c):
self.value_1 = a
self.value_2 = b
self.value_3 = c
def __iter__(self):
""" enables dict(object) functionality """
yield "key1", self.value_1
@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()
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case _ => MergeStrategy.first
}
docker stats $(docker ps --format={{.Names}})
@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")
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") =>

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
@mattkohl
mattkohl / .block
Last active June 10, 2016 09:54
Animated Donut Chart with Percentage
license: gpl-3.0