Skip to content

Instantly share code, notes, and snippets.

Avatar

Clément Delafargue divarvel

View GitHub Profile
View gist:b2b2cc8a3f5b309b7d4122f07a2f4b2c
❯ biscuit keypair
Generating a new random keypair
Private key: 53a4d7e7c10b186135b43fe231fa5f91923571a9619654091a23a5ae09d45d08
Public key: d0def12aeaaccd02cdfbab78f41e833085606e4dde78614a7e4bc87bc64a6126
❯ biscuit keypair --from-private-key 53a4d7e7c10b186135b43fe231fa5f91923571a9619654091a23a5ae09d45d08
Generating a keypair for the provided private key
Private key: 53a4d7e7c10b186135b43fe231fa5f91923571a9619654091a23a5ae09d45d08
Public key: d0def12aeaaccd02cdfbab78f41e833085606e4dde78614a7e4bc87bc64a6126
View Biscuit.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
module Biscuit
( authHandler
, RequireBiscuit
, checkBiscuit
, genBiscuitCtx
View Inline.hs
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
module Inline where
import Data.ByteString (ByteString, copy, packCStringLen)
import Foreign.Marshal.Alloc
import qualified Language.C.Inline as C
C.context (C.baseCtx <> C.bsCtx)
View Tumble.hs
#!/usr/bin/env stack
-- stack --resolver lts-14.20 --install-ghc ghci --package containers --package mtl --package optics
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedLabels #-}
View slides.md

% It's traverse! % Clément Delafargue % DDDDD 2020-05-15


Disclaimer

I'm not a regular DDD guy, i come from FP
View gist:608e1aaef1a780f6ca5d64eedcbb8db5
/*
Data format: the triangles are represented by a matrix. Each odd line is shifted down by 1/2.
0 represents nothing, 7 represents a full triangle.
[[7,7,7], [7,0,0]] translates to:
|\ |\
| \ | \
@divarvel
divarvel / gist:36aa1d1fd10c21919f3524f1842cccd3
Last active Jun 3, 2019
Config as Code? Yes, but cleanly. Try some Dhall
View gist:36aa1d1fd10c21919f3524f1842cccd3

There's always a point where we are tempted to replace config files (json, toml, yaml), with just code. It's handy, we get structure and abstraction, we can have little helper functions, proper comments (I'm looking at you, JSON). It's especially useful when the config is verbose, or very common. The flip side of going the config as code way, is that we lose a lot: updating config is updating the application itself (not very 12 factor compliant, and not user-friendly as well when using compiled languages). Worse, some arbitrary side effects can sneak into your configuration step. Another issue is that it becomes really hard to read or analyze config files without launching the application itself (bye linters, bye dependency checkers, bye organization-wide metrics). If you want to do that properly, it means building a way to output generated configuration, building a sandbox to run the application, and a few other unsavory contraptions.

All this issues stem from two things:

we have removed the boundary
@divarvel
divarvel / Lib.hs
Created Dec 31, 2018
A tale of servant clients
View Lib.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
View keybase.md

Keybase proof

I hereby claim:

  • I am divarvel on github.
  • I am clementd (https://keybase.io/clementd) on keybase.
  • I have a public key whose fingerprint is 78D3 430C 4600 7020 9F7A B0A2 6BFE 863C 2684 AD09

To claim this, I am signing this object:

View clementd.nix
self: super:
{
kakoune = super.kakoune.overrideAttrs (
drv: rec {
name = "kakoune-perso";
version = "divarvel";
src = super.fetchFromGitHub {
repo = "kakoune";
owner = "divarvel";
rev = "show-trailing-whitespace";