ScalaCheck 1.14.0 was just released with support for deterministic testing using seeds. Some folks have asked for examples, so I wanted to produce a Gist to help people use this feature.
These examples will assume the following imports:
| import org.scalacheck.cats.implicits._ | |
| import org.scalacheck.Gen | |
| import io.circe.{Decoder, Encoder} | |
| object Test extends App { | |
| case class X(i: Int) | |
| implicit val x: Encoder[X] = Wrapper[X].deriveInstance[Encoder] | |
| implicit val y: Decoder[X] = Wrapper[X].deriveInstance[Decoder].withErrorMessage("some custom error msg") | |
| val z: Gen[X] = Wrapper[X].lift(Gen.choose(0, 10)) |
| {- TODO: The Num and Fractional instances don't implement all methods. | |
| - In practice this is fine but for completeness they should be done. | |
| -} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| module NumericLits where | |
| data I = I | |
| i :: I |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE KindSignatures #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE UndecidableInstances #-} | |
| {-# LANGUAGE GADTs #-} | |
| {-# OPTIONS_GHC -Wall #-} | |
| module Main where |
| import shapeless._, record._ | |
| import io.circe._ | |
| import io.circe.syntax._ | |
| import io.circe.generic.encoding._ | |
| case class Person(name: String, age: Int) | |
| object Person { | |
| implicit val encodePerson: Encoder[Person] = | |
| ReprObjectEncoder.deriveReprObjectEncoder.contramap { person => |
To use media keys on the Ducky One 2 Skyline, you must record a macro to bind the media function to a hotkey combination, i.e. Fn plus some key.
Important: In the instructions below, "Press X+Y+Z" means press and hold key X, press and hold key Y, press and hold key Z in that order, and then release all three.
As an example, to bind Fn+PgUp to the play/pause media function:
In PureScript there are types of different kinds. Kinds are types for types. For example Int has kind Type, and we write it as Int :: Type. You can ask for the kind of a type in purs psci
> :k Int
TypeType constructors take types to other types. For example Array (which still needs another type to form a type a value could have, like Array Int):
NetworkManager supports WiFi powersaving but the function is rather undocumented.
From the source code: wifi.powersave can have the following value:
| # GIT heart FZF | |
| # ------------- | |
| is_in_git_repo() { | |
| git rev-parse HEAD > /dev/null 2>&1 | |
| } | |
| fzf-down() { | |
| fzf --height 50% --min-height 20 --border --bind ctrl-/:toggle-preview "$@" | |
| } |
| package com.dvMENTALmadness | |
| import akka.actor.ActorSystem | |
| import akka.stream.ActorMaterializer | |
| import akka.http.scaladsl.Http | |
| import akka.http.scaladsl.model._ | |
| import scala.concurrent.Await | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| import scala.concurrent.duration._ |