Skip to content

Instantly share code, notes, and snippets.

View emcfarlane's full-sized avatar
👨‍🚀
Nominal

Edward McFarlane emcfarlane

👨‍🚀
Nominal
View GitHub Profile
@emcfarlane
emcfarlane / bench_test.go
Created October 6, 2025 22:23
Benchmark leader election
package go
import (
"sync"
"testing"
)
func BenchmarkLeaderSyncMap(b *testing.B) {
// Simulate work that a leader performs.
doWork := func(key string) int {
// counter is a chunked firestore counter.
type counter struct {
id string
sync.Mutex
value big.Int
limit big.Int
}
type Counter struct {
ID string
// https://www.janestreet.com/puzzles/triads/
package main
import (
"context"
"fmt"
"strings"
"time"
)
@emcfarlane
emcfarlane / pair_sum_bst.py
Created January 13, 2017 15:05
Pair Sum Binary Search Tree
from collections import deque
class Node(object):
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right