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
type Params[N <: Num] <: Tuple = N match { | |
case 0 => EmptyTuple | |
case _ => Double *: Params[N - 1] | |
} | |
type Num = Singleton & Int | |
opaque type Multivector[DIM <: Num] = Array[Double] | |
transparent inline def vector[N <: Num](using v: ValueOf[N], ev: (N > 0) =:= true): Params[N] => Multivector[N] = | |
${ vectorImpl[N]('{valueOf[N]}) } |
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
brew install podman --head # you must use head due to issues with kind compatibility | |
# make sure docker desktop is deleted | |
sudo unlink /usr/local/bin/docker | |
sudo ln -s /usr/local/bin/podman /usr/local/bin/docker | |
podman machine init | |
podman machine start | |
podman machine ssh |
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
# Show pods on a node | |
kubectl get pods --all-namespaces -o wide --field-selector spec.nodeName=<node> |
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
sealed trait SecurityState | |
trait PlainText extends SecurityState | |
trait Hashed extends SecurityState | |
trait Confirmed extends SecurityState | |
trait Verified extends SecurityState | |
sealed trait UpdateState | |
trait New extends UpdateState | |
trait Confirmation extends UpdateState | |
trait Current extends UpdateState |
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
-- MySQL count same queries | |
SELECT substring_index(info, '/', 1), count(*) AS cnt | |
FROM INFORMATION_SCHEMA.PROCESSLIST | |
WHERE INFO IS NOT NULL | |
GROUP BY 1 | |
HAVING cnt>1 | |
ORDER BY cnt DESC; | |
-- MySQL show queries on DB |
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 shapeless.{ :+:, CNil, Coproduct } | |
import shapeless._ | |
val error1 = Coproduct[IllegalArgumentException :+: CNil](new IllegalArgumentException) | |
val error2 = Coproduct[NumberFormatException :+: CNil](new NumberFormatException) | |
type MyError = IllegalArgumentException :+: NumberFormatException :+: CNil | |
object MyErrorHandler extends Poly1 { | |
implicit def caseConfigNotFoundException: Case.Aux[IllegalArgumentException, String] = |
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 scala.language.higherKinds | |
trait Functor[F[_]] { | |
def map[A, B](fa: F[A])(f: A => B): F[B] | |
} | |
object Functor { | |
def apply[F[_]](implicit fun: Functor[F]): Functor[F] = fun | |
implicit class FunctorOps[F[_]: Functor, A](fa: F[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
import java.util.function.Function; | |
public abstract class Option<T> { | |
private static class Some<T> extends Option<T> { | |
private T val; | |
Some(final T val) { | |
this.val = val; | |
} |
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
def fromISOString(d: String): ZonedDateTime = | |
ZonedDateTime.parse(d, DateTimeFormatter.ISO_OFFSET_DATE_TIME).withZoneSameInstant(ZoneOffset.UTC) | |
def toISOString(d: ZonedDateTime) = d.withZoneSameInstant(ZoneOffset.UTC).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME) | |
// parsing a "date only" | |
LocalDate.parse(str).atStartOfDay(ZoneOffset.UTC) |
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 shapeless.ops.hlist.Length | |
import shapeless.{::, HList, HNil, LUBConstraint, Nat, Poly1, Succ} | |
import shapeless.Nat._ | |
abstract class Matrix[Col <: Nat, Row <: Nat, A] { | |
type RowLst <: HList | |
type ConLst <: HList | |
val data: ConLst | |
} |
NewerOlder