Skip to content

Instantly share code, notes, and snippets.

[
{
"Plan": {
"Node Type": "Limit",
"Startup Cost": 17024.84,
"Total Cost": 17024.87,
"Plan Rows": 10,
"Plan Width": 133,
"Actual Startup Time": 725.773,
"Actual Total Time": 725.775,
@hmac
hmac / Lib.hs
Last active March 4, 2020 15:53
Kleisli Data Representation
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE FlexibleContexts #-}
module Lib
( toText
, KVal
, int
, float
@hmac
hmac / lam.md
Last active November 22, 2019 12:56
Lam

Lam

Ruby and Haskell have a baby

Lam is a statically typed, purely functional programming language with full type inference. It's intended to be a gentle introduction to functional programming for developers not familiar with it. Lam is very close to Haskell, but eschews the more complex type system extensions of GHC. Lam has a large standard library, much like Ruby, and is targeted at similar use cases: scripts and web apps.

An example Lam program:

@hmac
hmac / prf.agda
Created June 25, 2019 10:42
All numbers are zero or greater than zero
-- Natural numbers
data Nat : Set where
Zero : Nat
Succ : Nat -> Nat
{-# BUILTIN NATURAL Nat #-}
-- The empty type (falsity)
data ⊥ : Set where
@hmac
hmac / postfix.hs
Last active May 14, 2019 07:51
Postfix experiments
module Postfix where
test = begin push 5 push 6 add end
begin f = f []
push s n f = f (n : s)
add (x : y : s) f = f (x + y : s)
@hmac
hmac / maintenance_mode.diff
Last active March 6, 2019 08:20
Stolon maintenance mode
diff --git a/cmd/keeper/cmd/keeper.go b/cmd/keeper/cmd/keeper.go
index ec4c9a5..a4a9020 100644
--- a/cmd/keeper/cmd/keeper.go
+++ b/cmd/keeper/cmd/keeper.go
@@ -958,6 +958,10 @@ func (p *PostgresKeeper) postgresKeeperSM(pctx context.Context) {
log.Errorw("clusterdata validation failed", zap.Error(err))
return
}
+ if cd.Cluster != nil && cd.Cluster.MaintenanceMode {
+ log.Infow("cluster in maintenance mode - not doing anything")
@hmac
hmac / fake-etcd-app.yaml
Created March 5, 2019 10:43
Node antiaffinity
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: fake-etcd-app
spec:
replicas: 5
template:
metadata:
labels:
@hmac
hmac / rule.rb
Last active January 4, 2019 13:38
Composable Validation
# frozen_string_literal: true
class Rule
def self.wrap(callable)
return callable if callable.is_a?(Rule)
Wrap.new(callable)
end
def &(other)
@hmac
hmac / simple.hs
Created December 12, 2017 21:51
Simple SQL AST
module Simple where
import Data.Foldable (fold)
import Data.List
data Query = Query Select [From] Where deriving Show
data From = FromTable String
| FromQuery Query String -- ^ last arg is the table alias
deriving Show
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NamedFieldPuns #-}
module StateMachine
( StateMachine(..)
, Transition(..)
, Guard(..)
, transitionTo
) where