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 scala.util.Try | |
object PathSerializer { | |
trait SerDe[A] { | |
// By using a path dependent type, we can be sure can deserialize without wrapping in Try | |
type Serialized | |
def ser(a: A): Serialized | |
def deser(s: Serialized): A | |
// If we convert to a generic type, in this case String, we forget if we can really deserialize |
apiVersion: extensions/v1beta1 | |
kind: PodSecurityPolicy | |
metadata: | |
name: restricted | |
annotations: | |
seccomp.security.alpha.kubernetes.io/allowedProfileNames: 'docker/default' | |
apparmor.security.beta.kubernetes.io/allowedProfileNames: 'runtime/default' | |
seccomp.security.alpha.kubernetes.io/defaultProfileName: 'docker/default' | |
apparmor.security.beta.kubernetes.io/defaultProfileName: 'runtime/default' | |
spec: |
val (recycleQueue, recycleSource) = | |
Source | |
.queue[SoilStateReading](100, OverflowStrategy.dropTail) | |
.prefixAndTail(0) | |
.map(_._2) | |
.toMat(Sink.head)(Keep.both) | |
.run() | |
StreamConverters.fromInputStream(() => this.getClass.getClassLoader.getResourceAsStream("sensors.log")) | |
.via(SoilStateReading.csvParser) | |
.merge(Source.fromFutureSource(recycleSource)) |
import play.api.libs.json.Json | |
object Main{ | |
def main(args: Array[String]): Unit = { | |
println( | |
Json.prettyPrint( | |
Json.toJson(Seq("Hello", "World", "Cow")) | |
) | |
) | |
} |
// Build Scala source code | |
val tree = q""" | |
object Test { | |
val a = 2 + 5 | |
def f(b: String) = { b + a.toString } | |
} | |
""" | |
val src = List(TreeNode(tree)) | |
// Build Scala target code |
Note: "Forked" from Latency Numbers Every Programmer Should Know
Event | Nanoseconds | Microseconds | Milliseconds | Comparison |
---|---|---|---|---|
L1 cache reference | 0.5 | - | - | - |
Branch mispredict | 5.0 | - | - | - |
L2 cache reference | 7.0 | - | - | 14x L1 cache |
Mutex lock/unlock | 25.0 | - | - | - |
tl;dr Generate a GPG key pair (exercising appropriate paranoia). Send it to key servers. Create a Keybase account with the public part of that key. Use your keypair to sign git tags and SBT artifacts.
GPG is probably one of the least understood day-to-day pieces of software in the modern developer's toolshed. It's certainly the least understood of the important pieces of software (literally no one cares that you can't remember grep's regex variant), and this is a testament to the mightily terrible user interface it exposes to its otherwise extremely simple functionality. It's almost like cryptographers think that part of the security comes from the fact that bad guys can't figure it out any more than the good guys can.
Anyway, GPG is important for open source in particular because of one specific feature of public/private key cryptography: signing. Any published software should be signed by the developer (or company) who published it. Ideally, consu
#!/bin/bash | |
if [[ $# -ne 1 ]]; then | |
echo "usage: $0 doc.md" | |
echo | |
echo 'Output will be printed to stdout, so you probably want to pipe to' | |
echo 'pbcopy or to a file or something.' | |
exit 1 | |
fi |
import shapeless._ | |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// THE IMPLICIT CLASS THAT ALLOWS TO CALL #copy ON ANY SEALED TRAIT INSTANCE | |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
object copySyntax { | |
implicit class CopySyntax[TypeToCopy](thingToCopy: TypeToCopy) { |