Skip to content

Instantly share code, notes, and snippets.

View divarvel's full-sized avatar

Clément Delafargue divarvel

View GitHub Profile
@divarvel
divarvel / continuation.js
Last active May 27, 2023 08:12
implementation of the continuation monad in JS
console.log("\033[39mRunning tests…");
function assertEquals(actual, expected, description) {
if(typeof actual === "undefined") {
console.error("\033[31m" + description + " not implemented\033[39m");
} else {
if(actual !== expected) {
console.error("\033[31m" + description + " failed, expected " + expected + ", got " + actual + "\033[39m");
} else {
console.log(description + " \033[32m ok\033[39m");
}
@divarvel
divarvel / biscuit-datalog.kak
Created April 6, 2023 07:55
Kakoune support for biscuit datalog
# http://https://datalog-biscuit-lang.org
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
# Detection
# ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*\.biscuit-datalog %{
set-option buffer filetype biscuitdl
}

+++ title = "Biscuit 3.0" description = "Version 3.0.0 of the biscuit reference implementation has been released" date = 2023-03-29T00:09:00+02:00 draft = false template = "blog/page.html"

[taxonomies] authors = ["clementd"]

import {Biscuit, Authorizer} from '@biscuit-auth/biscuit-wasm';
export function middleware(pubkey) {
return function(mkAuthorizer) {
return function(req, res, next) {
if(req.query.token) {
let parsed;
try {
let authorizer;
if(typeof mkAuthorizer === "function") {
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TypeFamilies#-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE NoImplicitPrelude #-}
module MyLib (main) where
import Relude
import Servant hiding (throwError)
@divarvel
divarvel / Tumble.hs
Last active December 26, 2021 15:37
#!/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 #-}
❯ 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
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
module Biscuit
( authHandler
, RequireBiscuit
, checkBiscuit
, genBiscuitCtx
{-# 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)

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


Disclaimer

I'm not a regular DDD guy, i come from FP