Skip to content

Instantly share code, notes, and snippets.

View etorreborre's full-sized avatar
🏠
Working from home

Eric Torreborre etorreborre

🏠
Working from home
View GitHub Profile
@etorreborre
etorreborre / concurrent-map.hs
Created December 4, 2020 07:32 — forked from Gabriella439/concurrent-map.hs
Low-tech concurrent hashmap
module ConcurrentMap where
import Control.Concurrent.STM.TVar (TVar)
import Control.Concurrent.STM (STM)
import Data.Hashable (Hashable)
import Data.HashMap.Strict (HashMap)
import Data.Vector (Vector)
import qualified Control.Concurrent.STM.TVar as TVar
import qualified Data.Hashable as Hashable
@etorreborre
etorreborre / afterEachAsync.scala
Last active November 25, 2020 17:51
Add async steps in specs2
import org.specs2.specification.create._
import org.specs2.control.producer.Producer._
/** How to add an async action after each example */
trait AfterEachAsync extends org.specs2.mutable.Specification:
override def map(fs: =>Fragments): Fragments =
super.map(fs.flatMap { f =>
if Fragment.isExample(f) then
emitAsync(List(f, step(afterAsync)))
else
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE PostfixOperators #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeApplications #-}
@etorreborre
etorreborre / deactivate.scala
Created September 16, 2020 07:41
Deactivate implicits in traits scopes with Dotty
import scala.concurrent.ExecutionContext
// this type is used by the implicit search to succeed in finding Not[C]
// when C can not be found as an implicit value
import scala.implicits.Not
trait ImplicitExecutionContextFromExecutionEnv:
/**
@etorreborre
etorreborre / deps.hs
Created June 15, 2020 13:31
Dependencies with RecordWildCards
newService :: Monad m => Logger m -> Tracer m -> Service m
newService Logger {..} Tracer {..} = Service {..}
where
doIt :: Int -> Text -> m ()
doIt n t = do
info "doing it" t
traceIt (show n)
@etorreborre
etorreborre / README.md
Created April 16, 2020 21:41 — forked from dcsobral/README.md
Scala Configurable Warnings

Pull request #8373 implementing issue 333 (but please note differences).

Pull request description follows:

This PR adds a -Wconf compiler flag that allows filtering and configuring compiler warnings (silence them, or turn them into errors).

It also integrates the fantastic silencer compiler plugin by @ghik into the compiler, which allows suppressing warnings locally using the @nowarn annotation.

@etorreborre
etorreborre / fileNameMacro.scala
Created April 5, 2020 17:44
Bug with Dotty macros?
case class FileName private(name: String)
/**
val fileName1: FileName = ToFileName("fileName1")
-- Error: /Users/etorreborre/projects/specs2/specs2-five/common/shared/src/test/scala/org/specs2/io/DirectoryPathSpec.scala:13:38
[error] 13 | val fileName1: FileName = ToFileName("fileName1")
[error] | ^^^^^^^^^^^
[error] | fileName1 is not a valid file name! It must not contain a /
@etorreborre
etorreborre / ArgsSpec.scala
Created October 12, 2019 20:44
Specs2 command line arguments
import org.specs2.main.CommandLine
// run from sbt with
//
// sbt> testOnly *ArgsSpec*
// sbt> testOnly *ArgsSpec* -- isOk
// sbt> testOnly *ArgsSpec* -- !isOk
//
// and see the difference
class ArgsSpec(args: CommandLine) extends mutable.Specification {
@etorreborre
etorreborre / audio.sh
Created August 30, 2019 08:47
restore mac audio
# from https://www.makeuseof.com/tag/sound-advice-fixing-common-mac-audio-problems-os-x/
sudo killall coreaudiod
@etorreborre
etorreborre / fzf.ghci
Last active March 15, 2021 17:43
fzf
How to Use Fzf in GHCi
by Vanessa McHale | 2019-08-27 01:27
I use fzf when I'm on the command-line. To configure GHCi to use fzf instead of haskeline's built-in search:
Put the following in $HOME/.haskeline:
bind: ctrl-r : f z f return
and the following in $HOME/.ghci: