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
object Mappable { | |
implicit class ToMapOps[A](val a: A) extends AnyVal { | |
import shapeless._ | |
import ops.record._ | |
def toMap[L <: HList](implicit | |
gen: LabelledGeneric.Aux[A, L], | |
tmr: ToMap[L] | |
): Map[String, Any] = { | |
val m: Map[tmr.Key, tmr.Value] = tmr(gen.to(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
object ControllerHttp4sEndpoints { | |
def routes(controller: Controller[F])( | |
implicit ... | |
): HttpRoutes[F] = { | |
val endpoints = ControllerEndpoints.create() | |
val getContainers = | |
endpoints.getSomething.toRoutes((controller.getSomething _).tupled) | |
val getContainerStatus = endpoints.doSomething.toRoutes(controller.doSomething) | |
) | |
NonEmptyList( |
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
object ControllerEndpoints { | |
def create(statusCodes: String => Int = _ => 422)( | |
implicit stringJsonCodec: JsonCodec[String], | |
listJsonCodec: JsonCodec[Result], | |
) = new DockerMonitorControllerFEndpoints { | |
override val getSomething | |
: Endpoint[String, GenericError, Result, Nothing] = | |
endpoint.get | |
.in("getContainers") |
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.annotation.StaticAnnotation | |
class query extends StaticAnnotation | |
class command extends StaticAnnotation | |
import io.circe.generic.JsonCodec | |
@JsonCodec case class GenericError( | |
message: String = "", | |
code: Int = 500 | |
) |
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
lazy val dockerMonitor = project | |
.settings(libraryDependencies ++= dependencies) | |
.settings( | |
tapiro / tapiroRoutesPath := "relative path to the routes", | |
tapiro / tapiroModelsPath := "relative path to the models", | |
tapiro / tapiroOutputPath := "relative path for the generated models", | |
tapiro / tapiroEndpointsPackage := cats.data.NonEmptyList("dockerMonitor", Nil), | |
) | |
.enablePlugins(SbtTapiro) | |
.dependsOn(authContracts) |
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 pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn | |
from sklearn.cluster import KMeans | |
import numpy as np | |
from scipy.spatial.distance import cdist, pdist | |
def elbow(df, n): | |
kMeansVar = [KMeans(n_clusters=k).fit(df.values) for k in range(1, n)] | |
centroids = [X.cluster_centers_ for X in kMeansVar] |
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 intervals | |
import scala.language.implicitConversions | |
import cats.Monoid | |
import cats.syntax.foldable._ | |
import cats.instances.list._ | |
import scala.math.Ordering | |
object Main extends App { | |
import Interval._ |
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 pandas as pd | |
def fillWithMean(df): | |
return df.fillna(df.mean()).dropna(axis=1, how='all') |
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
echo “very spoofy” | mail -s “much boring” recipient@domain.tld |
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 midi #pip install python-midi (https://github.com/vishnubob/python-midi) | |
pattern = midi.Pattern() | |
track = midi.Track() | |
pattern.append(track) | |
on = midi.NoteOnEvent(tick=0, velocity=100, pitch=60) | |
track.append(on) | |
off = midi.NoteOffEvent(tick=100, pitch=60) | |
track.append(off) | |
eot = midi.EndOfTrackEvent(tick=1) |
NewerOlder