Skip to content

Instantly share code, notes, and snippets.

Avatar

James Thompson jamesthompson

View GitHub Profile
@jamesthompson
jamesthompson / Pubsub.hs
Created Dec 1, 2020
Example pub/sub grpc interface with fused-effects
View Pubsub.hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE KindSignatures #-}
View keybase.md

Keybase proof

I hereby claim:

  • I am jamesthompson on github.
  • I am james_rth (https://keybase.io/james_rth) on keybase.
  • I have a public key ASDoRfTsm8xenyyW3WnK2OabszUxiN4gGDNit_NJtwfUsgo

To claim this, I am signing this object:

@jamesthompson
jamesthompson / install-stack-raspbian.sh
Created Feb 1, 2017
A script to install stack on Raspbian
View install-stack-raspbian.sh
#!/bin/sh
set +ex
# A script to install stack on Raspbian
# Use stack installer script to install stack
curl -sSL https://get.haskellstack.org/ | sh
# Use apt-get to install llvm
@jamesthompson
jamesthompson / GenericGogolDatastore.hs
Last active Aug 31, 2016
Gogol Datastore Generic Record Serializer
View GenericGogolDatastore.hs
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
@jamesthompson
jamesthompson / Triangle2.hs
Created Aug 30, 2016
Triangle string with alternating 0 and 1 characters
View Triangle2.hs
import Data.List (intersperse)
import Data.Monoid (mconcat)
triangleIO :: IO ()
triangleIO = putStrLn triangle
triangle :: String
triangle = mconcat . intersperse "\n" . fmap (intersperse ' ') $ cycle ['0']
where cycle x = x : (cycle x >>= growOne)
growOne (x:z) = [opp x:x:z]
@jamesthompson
jamesthompson / Triangle.hs
Last active Aug 29, 2016
Triangle 0 1 printing with comonadic stream
View Triangle.hs
import Control.Comonad (extract, (<<=), (=>>))
import Control.Monad (void)
import Data.Functor (fmap)
import Data.List (intersperse)
import Data.List.NonEmpty (NonEmpty, toList, (<|))
import Data.Monoid (mconcat)
import Data.Traversable (traverse)
import Prelude (IO, Int, String, drop, id, mod, otherwise,
putStrLn, take, undefined, ($), (.), (==))
View demoapp
{
"name": "DemoApp",
"preferences": [
{
"categories": [
{
"example": "guardian-stevebell: New opinion from Steve Bell at the Guardian",
"id": "news",
"matches": [
"guardian-stevebell: (.*)"
View TrentTree.hs
module TrentTree where
import Control.Monad.Trans.Class -- from the `transformers` package
import Control.Monad.Trans.Except -- from the `errors` package
import Data.Monoid ((<>))
import Data.Tree
import System.Directory (doesDirectoryExist,
getDirectoryContents)
import System.FilePath (combine, takeFileName)
View vb.nix
{
defaults =
{ config, pkgs, ... }:
{ deployment.targetEnv = "virtualbox";
deployment.virtualbox.memorySize = 2048; # Mb
deployment.virtualbox.headless = true;
};
}
View machines.nix
{ numZookeeperNodes ? 1 }:
with import <nixpkgs/lib>;
let
makeMachine = n: nameValuePair "zk-${toString n}"
({ config, pkgs, nodes, ... }: