Skip to content

Instantly share code, notes, and snippets.

@hmac
hmac / brew-leaves.rb
Created April 10, 2012 21:27
A rewrite of brew-leaves.rb that seems to work for me, unlike the current version.
# Outputs formulas that are installed but are not a dependency for
# any other installed formula.
# See: http://github.com/mxcl/homebrew/issues/issue/1438
require 'formula'
installed = HOMEBREW_CELLAR.children.select { |pn| pn.directory? }.collect { |pn| pn.basename.to_s }
deps = Formula.all.map do |f|
next unless installed.include? f.name
f.deps.map {|c| c.to_s }
@hmac
hmac / dirlist.rb
Created July 2, 2012 11:00
Print a list of folders and subfolders (1 level deep) in chosen directory
path = ARGV[0]
if !path
abort "No directory path supplied"
end
if !File.directory?(path)
abort "Path given is not a valid directory"
end
dir = Dir.new(path)
import grafica.*;
GPlot plot;
GPointsArray points;
int nPoints = 200;
int LEN = 200;
float[][] mesh = new float[1080][LEN];
float gaussian(float x, float mean, float stddev) {
@hmac
hmac / keybase.md
Last active September 30, 2015 21:47
Keybase

Keybase proof

I hereby claim:

  • I am hmac on github.
  • I am harrymaclean (https://keybase.io/harrymaclean) on keybase.
  • I have a public key whose fingerprint is F135 AC78 187C 468D 4A32 CA9E 5900 876C 9FFC AB3D

To claim this, I am signing this object:

# Thread an arbitrary number of arguments through a series of functions
def thread1(*funcs)
-> (*args) do
funcs.reduce(args) { |args, func| func.call(*args) }
end
end
a = ->(x) { x + 2 }
b = ->(x) { x * 2 }
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NamedFieldPuns #-}
module StateMachine
( StateMachine(..)
, Transition(..)
, Guard(..)
, transitionTo
) where
@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
@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 / 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 / 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")