Skip to content

Instantly share code, notes, and snippets.

View phderome's full-sized avatar

Philippe Derome phderome

  • Awake Security
  • Elora, ON
View GitHub Profile
@non
non / seeds.md
Last active April 12, 2024 09:18
Simple example of using seeds with ScalaCheck for deterministic property-based testing.

introduction

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.

simple example

These examples will assume the following imports:

@debasishg
debasishg / cqrs.session
Last active October 29, 2017 20:05
CQRS session on the REPL for Chapter 8
scala> import frdomain.ch8.cqrs.service._
import frdomain.ch8.cqrs.service._
scala> import Scripts._
import Scripts._
scala> import RepositoryBackedAccountInterpreter._
import RepositoryBackedAccountInterpreter._
scala> RepositoryBackedAccountInterpreter(composite)
@channingwalton
channingwalton / SetPerformance.scala
Created April 29, 2017 09:26
Benchmark for performance of .toSet
package set.performance
import java.util.concurrent.TimeUnit
import scala.concurrent.duration.FiniteDuration
/**
* On my machine the fast method takes < 2 ms, the slow one 2.2s
*/
object SetPerformance {
@milessabin
milessabin / shapeless-session.txt
Created April 1, 2016 12:29
shapeless on the Ammonite REPL with no dependencies other than an installed JDK. Many thanks to @przemekpokrywka for the idea, @alxarchambault for Coursier and @li_haoyi for Ammonite.
miles@frege:~$ ./shapeless.sh
Loading...
Welcome to the Ammonite Repl 0.5.2
(Scala 2.11.7 Java 1.8.0_51)
@ val l = 23 :: "foo" :: true :: HNil
l: Int :: String :: Boolean :: HNil = ::(23, ::("foo", ::(true, HNil)))
@
@viktorklang
viktorklang / linearize.scala
Created August 14, 2012 10:02
A Linearized version of Sequence
import scala.concurrent._
import scala.collection.mutable.Builder
import scala.collection.generic.CanBuildFrom
import language.higherKinds
/**
* Linearize asynchrnously applies a given function in-order to a sequence of values, producing a Future with the result of the function applications.
* Execution of subsequent entries will be aborted if an exception is thrown in the application of the function.
*/
def linearize[T, U, C[T] <: Traversable[T]](s: C[T])(f: T => U)(implicit cbf: CanBuildFrom[C[T], U, C[U]], e: ExecutionContext): Future[C[U]] = {