Skip to content

Instantly share code, notes, and snippets.

View nivekastoreth's full-sized avatar

James Maki nivekastoreth

View GitHub Profile
@nivekastoreth
nivekastoreth / nonfatal.sbt
Last active August 22, 2019 14:47
Temporary fix for disabling "-Xfatal-exceptions" in multi-module projects
// Place the contents of this file in ~/.sbt/1.0/nonfatal.sbt
// Or install by running the following command:
// curl https://gist.githubusercontent.com/nivekastoreth/7859422d43a8b397f4fb987bed172853/raw/nonfatal.sbt -o ~/.sbt/1.0/nonfatal.sbt
/**
* This method provides a mechanism for wrapping a given task key for all projects
* being tracked by the specified State. This means calling this while in a
* sub-project will still have global level changes applied across all projects
*
* This is a fairly heavy hammer and should only be used exceedingly sparingly
import org.specs2.matcher.MatchResult
import org.specs2.mutable.Specification
import scala.collection.mutable
class SubtractableTestSpec extends Specification {
"pass short circuit if not timed out" in {
val a: MatchResult[String] = "test" ==== "test"
val b: MatchResult[mutable.Buffer[Int]] = mutable.ArrayBuffer.empty[Int] must beEmpty
// Initial exploration of various means of writing similar expressions
// and what (if any) errors/warnings they emit when compiling
private def unitRight[A]: A \/ Unit = ().right[A]
// fails with: discarded non-Unit value
def test1: \/[String, Unit] = \/-(\/-(()))
def test2: \/[String, Unit] = ().right[String].map(_ => unitRight[String])
def test3: \/[String, Unit] = ().right[String].map { case _ => unitRight[String] }
@nivekastoreth
nivekastoreth / lettuce-correct-queue.log
Created April 20, 2018 16:58
Lettuce Client: DefaultEndpoint.QUEUE_SIZE becomes out of sync, preventing command queueing
# After each `Breakpoint reached` follows the stacktrace of where that breakpoint was, and after that it prints the value of `DefaultEndpoint.QUEUE_SIZE`
2018-04-20 14:40:52 UTC [disruptor-http-inbound-4] DEBUG i.l.c.RedisChannelHandler - dispatching command AsyncCommand [type=EVALSHA, output=ValueOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
0
2018-04-20 14:40:52 UTC [disruptor-http-inbound-4] DEBUG i.l.c.p.DefaultEndpoint - [channel=0x623c7065, /127.0.0.1:50087 -> localhost/127.0.0.1:8634, epid=0x2] write() writeAndFlush command AsyncCommand [type=EVALSHA, output=ValueOutput [output=null, error='null'], commandType=io.lettuce.core.protocol.Command]
2018-04-20 14:40:52 UTC [disruptor-http-inbound-4] DEBUG i.l.c.p.DefaultEndpoint - [channel=0x623c7065, /127.0.0.1:50087 -> localhost/127.0.0.1:8634, epid=0x2] write() done
2018-04-20 14:40:52 UTC [lettuce-nioEventLoop-10-3] DEBUG i.l.c.p.CommandHandler - [channel=0x623c7065, /127.0.0.1:50087 -> localhost/127.0.0.1:8634, chid=

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
jmaki@jmaki-pc ~
$ cat piping.sh
#!/bin/bash
while getopts oe arg; do
case "${arg}" in
o ) echo >&1 "This is writing to stdout" ;;
e ) echo >&2 "This is writing to stderr" ;;
* ) ;; # ignore
esac
done
jmaki@jmaki-pc ~
$ cat piping.sh
#!/bin/bash
echo >&1 "This is writing to stdout"
echo >&2 "This is writing to stderr"
jmaki@jmaki-pc ~
$ cat lmgtfy.sh
#!/bin/bash
search_string=$(echo "$@" | tr ' ' '+')