Skip to content

Instantly share code, notes, and snippets.

View DaveCTurner's full-sized avatar

David Turner DaveCTurner

View GitHub Profile
@DaveCTurner
DaveCTurner / tarsum
Last active April 8, 2020 16:38
SHA1 hashes of contents of TAR archive without extracting the archive first
#!/usr/bin/python
import sys
import tarfile
import hashlib
for filename in sys.argv[1:]:
print filename
with tarfile.open(filename, 'r') as tar:
for tarinfo in tar:
@DaveCTurner
DaveCTurner / gist:37258febb57ddaef99b0
Created January 5, 2015 09:21
The 'ClearBefore' monoid, adding the ability to clear a log generated by a Writer.
-- ClearBefore.hs
module ClearBefore where
import Data.Monoid
data ClearBefore a = ClearBefore Bool a
instance Monoid a => Monoid (ClearBefore a) where
mempty = ClearBefore False mempty
@DaveCTurner
DaveCTurner / Main.hs
Created February 10, 2015 21:59
Haskell checkout kata
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RecordWildCards #-}
module Main (main) where
import Control.Applicative
import Control.Monad
import Control.Monad.RWS
import Control.Monad.Trans.Either
@DaveCTurner
DaveCTurner / Main.hs
Created February 11, 2015 21:32
Haskell checkout kata II
{- a simpler implementation -}
module Main (main) where
import Test.Hspec
import Test.Hspec.QuickCheck
import Data.List
import qualified Data.Map as M
main :: IO ()
import Network.Socket
import System.Log.Logger
import System.Log.Handler.Syslog
openUDP = generalOpen
$ openlog_remote AF_INET "127.0.0.1" 514
openDevLog = generalOpen
$ openlog_local "/dev/log"
{-# LANGUAGE TupleSections #-}
import System.Random
import Control.Monad
import Data.List
import Text.Printf
main :: IO ()
main = do
let target = 4.7
@DaveCTurner
DaveCTurner / gist:0614baa193da5880c99d
Created August 7, 2015 09:40
Using curl to add a PR to an issue
curl https://api.github.com/repos/vincenthz/hs-certificate/pulls \
-XPOST --data-binary '{"issue":57,"head":"DaveCTurner:issue-57","base":"master"}' \
-H"Content-type: application/json" -u DaveCTurner -H"X-GitHub-OTP: nnnnnn" # asks for password
@DaveCTurner
DaveCTurner / RailwayPeriod.hs
Last active August 29, 2015 14:26
Railway period calculations
railwayPeriodStart :: Integer -> Integer -> Day
railwayPeriodStart yr pd
| pd == 1 = fromGregorian (yr - 1) 4 1
| otherwise = addDays (28 * pd) (dayZero yr)
railwayPeriodEnd :: Integer -> Integer -> Day
railwayPeriodEnd yr pd = addDays (-1) $ railwayPeriodStart yr' (pd' + 1)
where (yr', pd') = divMod (yr * 13 + pd) 13

Keybase proof

I hereby claim:

  • I am davecturner on github.
  • I am dcturner (https://keybase.io/dcturner) on keybase.
  • I have a public key ASAZdCj2ryspkWzhpFttsuadl4bwlg4fgKtJ_oaaHRjzowo

To claim this, I am signing this object:

Linearisability vs Sequential Consistency

Linearisability is a really rather strong property on a distributed system. There is a good discussion in [1] with some much more precise definitions on which I'm going to base this article.

The setup is a distributed system with some client processes which can perform operations (think: RPCs) on some remote data objects (think: a single-value register). The operations, being remote, take some nonzero amount of time between the client invoking the operation and being notified of its