Skip to content

Instantly share code, notes, and snippets.

val predictedOrdersChecks = ChecksSuite("orders",
dualDsChecks = Map(
DescribedDsPair(DescribedDs(orders, "orders"), DescribedDs(predictedOrders, "predictedOrders")) ->
Seq(
DualMetricCheck(CountDistinctValuesMetric(List("customerId")), CountDistinctValuesMetric(List("customerId")),
"predicted orders present for every customer", MetricComparator.metricsAreEqual)
)
)
)
ArbSingleDsCheck("less than 5 flash sales per customer") { ds =>
val tooManyFlashSaleCustomerCount = ds
.filter(col("orderType") === "Flash Sale")
.groupBy("customerId").agg(count("orderId").as("flashSaleCount"))
.filter(col("flashSaleCount") > 5)
.count
if (tooManyFlashSaleCustomerCount > 0)
RawCheckResult(CheckStatus.Error, s"$tooManyFlashSaleCustomerCount customers had too many flash sales")
else
val ordersChecks = ChecksSuite("orders",
singleDsChecks = Map(
DescribedDs(orders, "orders") -> Seq(
SingleMetricCheck.complianceCheck(AbsoluteThreshold(0.9, 1),
ComplianceFn(col("orderType") === "Sale")),
SingleMetricCheck.complianceCheck(AbsoluteThreshold(1, 1),
ComplianceFn(col("orderValue") < 0),
MetricFilter(col("orderType") === "Refund")),
SingleMetricCheck.distinctValuesCheck(AbsoluteThreshold(Some(20), None),
List("itemId")),
@timgent
timgent / remote-board-games.md
Last active April 5, 2020 10:29
Remote Board Games
[root@8881a24c5485 openresty-1.9.15.1]# ./configure --add-module=../naxsi-master/naxsi_src
platform: linux (linux)
cp -rp bundle/ build
cd build
cd LuaJIT-2.1-20160517
gmake TARGET_STRIP=@: CCDEBUG=-g CC=cc PREFIX=/usr/local/openresty/luajit
==== Building LuaJIT 2.1.0-beta2 ====
gmake -C src
gmake[1]: Entering directory `/root/openresty-1.9.15.1/build/LuaJIT-2.1-20160517/src'
HOSTCC host/minilua.o
package com.timmeh.openhr.openholidays.model
import slick.driver.H2Driver.api._
import slick.collection.heterogeneous._
import syntax._
//// This file demonstrates how to map more than 22 columns to a nested case class using a HList
class LargeTableExample3(tag: Tag)
extends Table[LargeUnnestedTableRow](tag, "LARGE_TABLE") {
def id = column[Int]("ID", O.PrimaryKey)
package com.timmeh.openhr.openholidays.model
import com.timmeh.openhr.openholidays.model.Helpers.MyHList
import slick.collection.heterogeneous._
import slick.collection.heterogeneous.syntax._
import slick.driver.H2Driver.api._
// Alias this type so we don't have to keep repeating it in method definitions
object Helpers {
type MyHList =
import slick.driver.H2Driver.api._
// This file demonstrates how to map more than 22 columns to a nested case class using a custom mapping
class LargeTableExample2(tag: Tag)
extends Table[LargeTableRow](tag, "LARGE_TABLE") {
def idToD = (id, a, b, c, d)
def id = column[Int]("ID", O.PrimaryKey)
def a = column[String]("A")
def b = column[String]("B")
def c = column[String]("C")
package com.timmeh.openhr.openholidays.model
import slick.driver.H2Driver.api._
import slick.lifted.{ProvenShape, ForeignKeyQuery}
// This file demonstrates how to map many columns into a nested case class using projections for each case class
class LargeTableExample1(tag: Tag)
extends Table[LargeTableRow](tag, "LARGE_TABLE") {
def idToD = (id, a, b, c, d)
def id = column[Int]("ID", O.PrimaryKey)
import slick.driver.H2Driver.api._
case class Holiday(id: Int, employeeId: Int, holDate: java.sql.Date, holDayType: String, holType: String)
class Holidays(tag: Tag)
extends Table[Holiday](tag, "HOLIDAYS") {
def id = column[Int]("HOL_ID", O.PrimaryKey)
def employeeId = column[Int]("EMP_ID")
def holDate = column[java.sql.Date]("HOL_DATE")
def holDayType = column[String]("HOL_DAY_TYPE")