Skip to content

Instantly share code, notes, and snippets.

View frasertweedale's full-sized avatar

Fraser Tweedale frasertweedale

View GitHub Profile
@frasertweedale
frasertweedale / rev.idr
Created December 3, 2014 08:34
proofs of list reverse properties in Idris
module Rev
rev : List a -> List a
rev [] = []
rev (x::xs) = rev xs ++ [x]
revUnit : rev [a] = [a]
revUnit = Refl
@frasertweedale
frasertweedale / Middleware.hs
Last active August 21, 2017 19:32
WAI Middleware to modify request headers
{-# LANGUAGE OverloadedStrings #-}
module Middlware where
import Control.Monad ((<=<))
import qualified Data.ByteString as B
import Network.HTTP.Types
import Network.Wai
@frasertweedale
frasertweedale / TLS.hs
Last active August 29, 2015 14:16
Example TLS API
module TLS where
-- |
--
-- This is something like what I want from a TLS API. The TLS
-- library should provide a single call: "give me a secure
-- connection to $HOST". All possibilities for authenticating the
-- peer, including CRL, OCSP, DANE, etc, should be accounted for in
-- a configuration type, and the library should take care of all the
-- details.
@frasertweedale
frasertweedale / testFfi.hs
Created May 21, 2015 12:16
YOW Lambda Jam GHCJS workshop example
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Int
import System.Timeout
import Control.Monad
import Control.Exception
@frasertweedale
frasertweedale / deploy.sh
Last active January 6, 2016 05:28
git: commit hakyll compiled site to gh-pages branch
export GIT_INDEX_FILE=$PWD/.git/index-deploy
export GIT_WORK_TREE=$PWD/_site
REF=refs/heads/gh-pages
git read-tree "$REF"
git add --all --intent-to-add
git diff --quiet && exit
git add --all
TREE=$(git write-tree)
COMMIT=$(git commit-tree "$TREE" -p "$REF" -m "snapshot $(date '+%y-%m-%d %H:%M')")
git update-ref "$REF" "$COMMIT"
@frasertweedale
frasertweedale / Grammar.hs
Last active December 12, 2015 07:44
Prism-based parser/printer experiment
-- This file is a parsing experiment
-- Copyright (C) 2015 Fraser Tweedale
--
-- This software is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Affero General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
@frasertweedale
frasertweedale / caacl-future.rst
Created October 24, 2016 23:34
Discussion: CA ACL enhancements

Future of CA ACLs and cert-request validation

This document details some limitations in the current CA ACL and certificate request features and proposes (at a very high-level) a way forward for FreeIPA to support more use cases and give administrators more fine-grained control of certificate issuance authorisation. Feedback and additional use cases are sought.

The current controls governing certificate issuance authorisation are limited, falling short for a number of important use cases:

Refactoring with type classes and optics

Often when writing programs and functions, one starts off with concrete types that solve the problem at hand. At some later time, due to emerging requirements or observed patterns, or just to improve code readability and reusability, we refactor to make our code more polymorphic. The importance of not breaking your API typically ranges from nice to have (e.g. minimises rework but not essential) to paramount (e.g. in a popular, foundational library).

@frasertweedale
frasertweedale / dogtag-spnego.py
Last active May 10, 2019 04:30
Example program for HTTP SPNEGO
import base64
import gssapi
import gssapi.raw
import requests
alice = gssapi.Name('[email protected]')
rcreds = gssapi.raw.acquire_cred_with_password(alice, '4me2Test').creds
creds = gssapi.Credentials(rcreds)
svcname = gssapi.Name('[email protected]', gssapi.NameType.hostbased_service)
@frasertweedale
frasertweedale / Main.hs
Created April 22, 2017 00:08
f :: Fold s a -> Fold (a -> Bool, s) a
{-# LANGUAGE RankNTypes #-}
import Data.Functor.Contravariant (phantom)
import Control.Lens
main = print $ toListOf (f folded) (even, [1,2,3,4])
f :: Fold s a -> Fold (a -> Bool, s) a
f l agb (f, s) = phantom $ traverseOf_ (l . filtered f) agb s