Skip to content

Instantly share code, notes, and snippets.

View frasertweedale's full-sized avatar

Fraser Tweedale frasertweedale

View GitHub Profile
@frasertweedale
frasertweedale / Workflow.hs
Last active May 20, 2020 01:22
workflow library
{-# LANGUAGE KindSignatures #-}
module Workflow where
import Data.Bool (bool)
data Workflow a r
= Decision a (Workflow a r) (Workflow a r)
| Guard a (Workflow a r)
@frasertweedale
frasertweedale / certbot-dns-ipa.py
Created May 13, 2020 03:37
certbot-dns-ipa.py
#!/usr/bin/python3
import os
from dns import resolver
from ipalib import api
from ipapython import dnsutil
certbot_domain = os.environ['CERTBOT_DOMAIN']
certbot_validation = os.environ['CERTBOT_VALIDATION']
if 'CERTBOT_AUTH_OUTPUT' in os.environ:
@frasertweedale
frasertweedale / bfpg-news-2020-03.rst
Last active March 10, 2020 02:16
bfpg-news-2020-03
@frasertweedale
frasertweedale / hedgehog.txt
Last active February 27, 2020 02:04
hedgehog stuff
message round trip with From header: FAIL (47.81s)
✗ message round trip with From header failed at tests/Message.hs:106:3
after 866 tests and 69 shrinks.
┏━━ tests/Message.hs ━━━
100 ┃ prop_messageFromRoundTrip :: Property
101 ┃ prop_messageFromRoundTrip = property $ do
102 ┃ from <- forAll genMailbox
┃ │ Mailbox (Just "\r\n") (AddrSpec "!" (DomainDotAtom ("!" :| [])))
103 ┃ let
@frasertweedale
frasertweedale / bfpg-news-2020-01.rst
Last active January 21, 2020 06:54
BFPG news 2020-01
@frasertweedale
frasertweedale / bug.rst
Created December 5, 2019 06:46
Horrible haskell FFI concurrency talloc bug

Notes about a very hard to debug bug:

Eventually I deduced that it was lack of thread safety in talloc causing corruption and (most of the time) an abort() when talloc itself detected the corruption.

So, I created pthread mutexs around all operations that might do talloc things. Including routines called from finalisers.

This resulted in instant deadlocks. Why? forkIO was being used, instead of forkOS to create bound threads. Because Haskell execution capability can move among OS threads,

@frasertweedale
frasertweedale / add-index.ldif
Created October 25, 2019 01:56
389DS add index LDIF
dn: cn=issuername,cn=index,cn=ipaca,cn=ldbm database, cn=plugins, cn=config
objectClass: top
objectClass: nsIndex
nsindexType: eq
nsindexType: pres
nsindexType: sub
nsSystemindex: false
cn: issuername
@frasertweedale
frasertweedale / instructions.md
Last active August 8, 2019 03:36
unregister dup packages in cabal store

Installing a library explicitly via cabal v2-install lib:blah installs it in the package-db and exposes it. If there are multiple exposed instances of a library available, GHC chooses an unspecified instance (ref). Therefore it is sometimes necessary to manually hide or unregister conflicting versions of packages.

Look for library package-id in cabal install output:

Installing library in /home/ftweedal/.cabal/store/ghc-8.4.4/incoming/new-8790/home/ftweedal/.cabal/store/
ghc-8.4.4/purebred-icu-0.1.0.0-c850b6a0c804167cfc4542bce128a8714de643dcfd6a7114ff42f7e11986c81d/lib
[T470s:~/dev/hs-dynload-experiment] ftweedal% ghc -c Profile.hs
Loaded package environment from /home/ftweedal/dev/hs-dynload-experiment/.ghc.environment.x86_64-linux-8.4.4
[T470s:~/dev/hs-dynload-experiment] ftweedal% nm Profile.o
U base_GHCziBase_zpzp_closure
U ghczmprim_GHCziTypes_Module_con_info
U ghczmprim_GHCziTypes_TrNameS_con_info
0000000000000000 D Profile_resource_closure
0000000000000020 T Profile_resource_info
0000000000000030 D Profile_zdtrModule_closure
@frasertweedale
frasertweedale / rmdecl.hs
Last active July 19, 2019 06:51
Haskell script to remove bindings from Haskell source files
-- Copyright (C) 2019 Fraser Tweedale
--
-- This program 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
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the