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 / gist:e71d28c35d1142613656a0476a1634ca
Created September 29, 2023 11:08
copy the most recent commit to the clipboard
```
git log -1 --pretty=full | head -1 | awk '{ print $2 }' | pbcopy
```
@etorreborre
etorreborre / generate-ssh-key.sh
Created October 20, 2021 14:09 — forked from denisgolius/generate-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa
@etorreborre
etorreborre / ffunctor.hs
Created October 9, 2021 09:10
Deriving FFunctor?
{-
It would be nice to be able to derive a `FFunctor` instance for some data types as
shown below
-}
class FFunctor f where
ffmap :: (forall a. m a -> n a) -> f m -> f n
-- can we define a default ffmap which would work when m :: Type -> Type?
-- default ffmap
@etorreborre
etorreborre / registry.hs
Last active October 9, 2021 09:10
Dependency injection with registry
{-
See https://www.reddit.com/r/haskell/comments/q1oyws/dependency_injection_using_a_recordoffunctions
for full context
-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE DeriveGeneric #-}
@etorreborre
etorreborre / assertions.scala
Created August 16, 2021 11:30
Assertion examples in specs2-5.0.0-RC-03
package examples
import org.specs2.*
class AssertionSpec extends Specification:
def is = s2"""
authors must be correct $book1
authors must be correct $book2
book must be correct $book3
"""
@etorreborre
etorreborre / wishlist-answer.md
Created August 12, 2021 16:43
Response to "My specs(3?) wishlist"

Prescriptive Structural Syntax

I am sorry but I actually prefer the other style of specification! The main reason is that I think that encourages me to think about writing some text about what I am testing, and why I am testing it this way (that doesn't mean that I necessarily do it :-)).

Enforced Matcher Uniformity

I hear you and I indeed simplified all must expressions to be a must b, and then a must not(b).

@etorreborre
etorreborre / optics-witch.hs
Created July 14, 2021 07:22
Optics with the Witch library
{-# LANGUAGE TemplateHaskell #-}
import qualified Data.Text as T
import Optics as O
import Protolude hiding ((%), from)
import Witch
import Data.Coerce
-- 2 different temperature types
newtype Kelvin = Kelvin Double deriving (Eq, Show, Num)
@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 #-}