This file contains 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 com.fasterxml.jackson.core.Base64Variants | |
import com.google.protobuf.ByteString | |
import com.google.protobuf.Descriptors.FieldDescriptor.JavaType | |
import com.google.protobuf.Descriptors.{ EnumDescriptor, EnumValueDescriptor, FieldDescriptor } | |
import com.trueaccord.scalapb.{ GeneratedMessage, GeneratedMessageCompanion, Message } | |
import play.api.data.validation.ValidationError | |
import play.api.libs.json._ | |
import scala.util.{ Failure, Success, Try } |
This file contains 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 | |
HOST="???" # address of the vpn | |
LASTPASS_ENTRY="???" # entry under which the password is saved in last pass | |
USERNAME=$(lpass show --sync=auto --username $LASTPASS_ENTRY) | |
PASSWORD=$(lpass show --sync=auto --password $LASTPASS_ENTRY) | |
# escaping the special chars in the password to allow sed-ing it | |
ESC_PWD=$(echo $PASSWORD | sed -e 's/[]\/$*.^[]/\\&/g') |
This file contains 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
package teikametrics | |
import cats.effect.{Sync, Timer} | |
import scala.concurrent.duration.FiniteDuration | |
import scala.concurrent.blocking | |
import cats.syntax.all._ | |
object JavaFuture { | |
// Alias for more friendly imports |
This file contains 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
abstract class FoldableFromTraverse[F[_]] extends Traverse[F] { | |
override def foldMap[A, B: Monoid](fa: F[A])(f: A => B): B = | |
traverse[Const[B, ?], A, B](fa)(a => Const(f(a))).getConst | |
private def andThenMonoid[A]: Monoid[A => A] = new Monoid[A => A] { | |
def combine(f: A => A, g: A => A) = f andThen g | |
def empty: A => A = (a: A) => a | |
} |
This file contains 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 that allows values to be discarded in a visible way | |
* | |
* Thanks https://github.com/tabdulradi for the Trick | |
*/ | |
object ValueDiscard { | |
/** |
This file contains 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
package ammonite | |
package $file | |
import _root_.ammonite.interp.InterpBridge.{ | |
value => interp | |
} | |
import _root_.ammonite.interp.InterpBridge.value.{ | |
exit | |
} | |
import _root_.ammonite.main.Router.{ | |
doc, |
This file contains 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 $ivy.`org.typelevel::cats-core:1.0.1` | |
import cats.data.NonEmptyList | |
case class ABC(a : Int, b : Long, c : String) | |
case class NelWrapper(nel: NonEmptyList[Int]) | |
val w = NelWrapper(NonEmptyList.of(1,2,3,4)) |
This file contains 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
# See https://debian-administration.org/article/317/An_introduction_to_bash_completion_part_2 | |
__mill() | |
{ | |
local cur prev opts | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
opts="$(echo $(mill resolve __ 2>/dev/null ) | sed 's/ / /g')" | |
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | |
return 0 |
This file contains 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
package presentation | |
import matryoshka.data.Fix | |
import scalaz.Functor | |
object Presentation extends App { | |
// 1 : abstract recursion away |
This file contains 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
// Look up ammonite if you're wondering what this syntax is | |
import $ivy.`org.typelevel::cats-core:1.0.0-MF` | |
import cats._ | |
import cats.syntax.functor._ | |
import cats.syntax.traverse._ | |
sealed trait Nat[+A] | |
case object Zero extends Nat[Nothing] | |
case class Succ[A](a : A) extends Nat[A] |