This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final case class IPV6Full private (value: String) extends AnyVal | |
object IPV6Full { | |
val DataSegments: Int = 8 | |
def fromString(s: String): Either[Throwable, IPV6Full] = { | |
def buildExpansion0s(cnt: Int): String = { | |
Iterator.continually('0').take(cnt).mkString(":") | |
} | |
s match { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e; | |
# Ths script | |
me="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"; | |
# Args | |
MANAGER_IP=$1 | |
STACK_NAME=$2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cats._, implicits._ | |
import diesel.diesel | |
object DieselDemo extends App { | |
@diesel | |
trait Maths[F[_]] { | |
def int(i: Int): F[Int] | |
def add(l: F[Int], r: F[Int]): F[Int] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
split :: Eq a => a -> [a] -> [[a]] | |
split s = go [] | |
where | |
go acc [] = reverse acc | |
go acc rs = | |
let (next, remaining) = span (/= s) rs | |
in go (next : acc) (drop 1 remaining) | |
join :: t -> [[t]] -> [t] | |
join j [] = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import freek._ | |
object KVStore { | |
sealed trait DSL[A] | |
final case class Put[A](key: String, v: A) extends DSL[Unit] | |
final case class Get[A](key: String) extends DSL[Option[A]] | |
} | |
object WebIO { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Ev[A] { | |
} | |
object Ev { | |
implicit def witnessSelfTypeEqualsSelf[A <: { type SelfType }](implicit ev: A#SelfType =:= A) = new Ev[A] {} | |
} | |
class A { | |
type SelfType = A |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Ev[A] { | |
} | |
object Ev { | |
implicit def evProvider[A <: { type SelfType }](implicit ev: A#SelfType =:= A) = new Ev[A] {} | |
} | |
class A { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object FoldRight { | |
def apply[A, B](list: Seq[A])(init: B)(f: (A, B) => B): B = { | |
@scala.annotation.tailrec | |
def step(current: Seq[A], thunks: List[B => B]): B = current match { | |
case Nil => init | |
case Seq(last) => thunks.foldLeft(f(last, init)) { (acc, next) => next(acc) } | |
case Seq(x, xs @ _*) => step(xs, { acc: B => f(x, acc) } +: thunks) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function x = featuresVector(indices, featureVectorSize) | |
%FEATURESVECTOR takes in a indices vector, a featureVectorSize and produces a feature vector | |
%where x(i) is 1 if i exists in the indices and 0 if it does not | |
% x = FEATURESVECTOR(indices featureVectorSize) takes in a indices vector and a featureVectorSize and | |
% produces a feature vector from the indices. | |
indexed = eye(n)(word_indices, :); | |
[rows, cols] = size(indexed); | |
if rows == 1 | |
x = indexed' > 0; | |
elseif rows == 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.annotation.tailrec | |
sealed trait Bounce[A] | |
case class Done[A](result: A) extends Bounce[A] | |
case class Cont[A](thunk: () => Bounce[A]) extends Bounce[A] | |
object Trampoline { | |
/** | |
* Bounce away |