To write a zookeeper client, it is neccessary to understand
the protocol used to communicate with it. Unfortunately, this
protocol is not documented. In this example, we use tcpflow
to dump both the read and write channel of the TCP connection
that zkCli.sh
uses to connect with the zookeeper server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is an example of overriding a GHC core Haskell library (like | |
# bytestring, containers, text, unix, etc) when building a Haskell package. | |
let default-nixpkgs = | |
builtins.fetchTarball { | |
# nixpkgs haskell-updates branch as of 2019/09/15. | |
url = "https://github.com/NixOS/nixpkgs/archive/a51b3367ab6acc72630da0bad50ce14fa86996d0.tar.gz"; | |
sha256 = "05d3jxxk5dxzs9b3nan16lhkrjnzf0bjd4xy66az86fsafnrr9rd"; | |
}; | |
in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -Eeuxo pipefail | |
# Set up git | |
git init | |
gitignore haskell | |
echo '*.cabal' >> .gitignore | |
# Set up niv | |
niv init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE EmptyCase #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE TypeInType #-} | |
module Pokemon where | |
import Data.Kind (Type) | |
import Data.Void (Void) | |
import Type.Reflection ((:~:)(..)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Numeric.Natural (Natural) | |
import qualified Data.Semigroup | |
-- | @fibonacci n@ computes the @nth@ fibonacci number efficiently using infinite | |
-- precision integer arithmetic | |
-- | |
-- Try @fibonacci 1000000@ | |
fibonacci :: Natural -> Natural | |
fibonacci n = x01 (Data.Semigroup.mtimesDefault n m) |
NewerOlder