Skip to content

Instantly share code, notes, and snippets.

View divarvel's full-sized avatar

Clément Delafargue divarvel

View GitHub Profile
@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)
❯ 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)
@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 #-}

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


Disclaimer

I'm not a regular DDD guy, i come from FP
/*
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:
|\ |\
| \ | \