Skip to content

Instantly share code, notes, and snippets.

View tonyhb's full-sized avatar

Tony Holdstock-Brown tonyhb

View GitHub Profile
tonyhb / go.yml
Last active February 19, 2021 19:40
Randomize go package specs on github actions
View go.yml
name: Build & Test
branches: [ develop, master ]
branches: [ develop, master ]
tonyhb /
Last active March 26, 2022 20:16
Event sourcing thoughts

I've been planning out an event sourcing like system for our healthtech startup, and you're definitely right re namespacing and versioning.

I explicitly keep a version in the event - which is a date. It's similar in how Stripe versions their API. We're also planning to handle the events in the same way as stripe's API: each event has side effects; the side effects may change depending on the version and each version has its own application logic (cascading, so you can have 2018-08-01 run all of 2018-07-30 plus its own changes).

This lets us replay events as they happened, run an event using two different versions and perform only the diffs etc.

Our system is probably not a typical CQRS/event sourcing setup.

The event system itself idempotent: you take an event with all input data necessary to run the event (form data, necessary current state), so the system can run independently. This means that every event is typed such that the input data dictates what is necessary.

tonyhb / genesis_public_key
Created March 6, 2018 01:36
View genesis_public_key
tonyhb /
Created January 11, 2018 00:28
/* result represents either a success or an error for an operation. It can hold
a resource of any type - ie. a user, treatment etc. */
type result('resource) =
| Ok('resource)
| Error('resource, string);
/* Event represents a single event within our system */
type event('data, 'resource) = {
/* The ID of the user authoring the event */
author: string,
View react-native.nix
{ pkgs ? import <nixpkgs> {} }:
jdk = pkgs.jdk8;
androidsdk = pkgs.androidenv.androidsdk_6_0_extras;
fhs = pkgs.buildFHSUserEnv {
name = "android-env";
targetPkgs = pkgs: with pkgs; [
tonyhb / gist:c78c953b900f3a9eb63ddb4fc8686a0b
Last active February 23, 2018 00:29
Debian machine setup
View gist:c78c953b900f3a9eb63ddb4fc8686a0b
# Install kernel 4.14
echo 'deb stretch-backports main' | sudo tee /etc/apt/sources.list.d/stretch-backports.list
sudo apt-get update
sudo apt-get -t stretch-backports install linux-image-amd64
# Install Docker
sudo apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
tonyhb / page.go
Last active August 29, 2015 14:18
Exposing atomic and transactional database methods
View page.go
package models
import (
type Page struct {
Id int64
Name string
tonyhb / click.rb
Created September 18, 2014 20:48
View click.rb
# spec/support/click.rb
module Capybara
module Node
class Element < Base
# Override the default implementation of click so that whenever we click
# on something, we also wait for any ajax requests to finish.
def click
synchronize { }
tonyhb / main.go
Last active August 29, 2015 14:05
Using variable functions to make testing easier
View main.go
// By assigning next to a variable we can swap out the hello() function in testing with a custom
// implementation
var h = hello
func main() {
func hello() string {
View gist:4061f439d4f221767c12
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
" Plugins here