Skip to content

Instantly share code, notes, and snippets.

Ben Mabey bmabey

Block or report user

Report or block bmabey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Brewfile
brew 'ack'
brew 'ag'
brew 'coreutils'
brew 'bash-completion'
brew 'openssl'
brew 'readline'
brew 'ispell'
brew 'wget'
brew 'tree'
brew 'autoenv'
@bmabey
bmabey / bwmorph.py
Created May 24, 2018
Python implementation of matlab's `bwmorph` function for the operations:`thin`, `spur`, `bracnhes`, and `endpoints`
View bwmorph.py
"""
Functions that implement some of the same functionality found in Matlab's bwmorph.
`thin` - was taken and adapted from https://gist.github.com/joefutrelle/562f25bbcf20691217b8
`spur` - Not perfect but pretty close to what matlab does via LUTs
`endpoints` - lines up perfectly with matlab's output (in my limited testing)
`branches` - this results in more clustered pixels than matlab's version but it pretty close
"""
import numpy as np
import scipy.ndimage as ndi
@bmabey
bmabey / prometheus-text004.instaparse
Last active Mar 4, 2018
instaparse parser for prometheus text format exporter (text version 0.0.4)
View prometheus-text004.instaparse
(* see https://github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md#text-format-details *)
statements = (type-def | help | metric)*
type-def = <"# TYPE "> metric-name <space> type <newline>?
type = #"counter|gauge|histogram|summary|untyped"
help = <"# HELP "> metric-name <space> docstring <newline>?
metric = metric-name labels? <space> value (<space> timestamp)? <newline>?
labels = <'{'> label-name label-value {<','> label-name label-value} <','>? <'}'>
(* the below doesn't take into account escaping but probably not an issue for our use case *)
View multiple_return_specs_compojure_api.clj
(require '[spec-tools.core :as st])
(require '[spec-tools.spec :as st.s])
(require '[clojure.spec.alpha :as s])
(s/def ::cheese st.s/string?)
(s/def ::stuff st.s/int?)
(s/def ::bar (st/spec (s/keys :req-un [::cheese])))
(s/def ::foo (st/spec (s/keys :req-un [::stuff])))
(s/def ::response (s/or :b ::bar :f ::foo))
View Brewfile
brew 'ack'
brew 'ag'
brew 'coreutils'
brew 'bash-completion'
brew 'openssl'
brew 'readline'
brew 'ispell'
brew 'wget'
brew 'tree'
brew 'autoenv'
@bmabey
bmabey / joblib_numpy_memoziation_bug.ipynb
Created Sep 8, 2016
Notebook illustrating a bug in joblib
View joblib_numpy_memoziation_bug.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Hungarian.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bmabey
bmabey / Bayesian Update.ipynb
Created Oct 30, 2014
A tutorial/lab for learning about bayesian updating using IPython Notebook
View Bayesian Update.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bmabey
bmabey / sublist.clj
Last active Aug 29, 2015
sublist generator for clojure test.check... which has better shrinking properites?
View sublist.clj
;; my first version taking advantage of the new shuffle generator introduced in 0.6...
(defn sublist1
[coll]
(-> (gen/tuple (gen/shuffle coll) (gen/choose 0 (count coll)))
(gen/bind (fn [[coll* how-many]]
(gen/return (take how-many coll*))))))
;; version inspired by http://roberto-aloi.com/erlang/notes-on-erlang-quickcheck/
;; sublist(L0) ->
;; ?LET(L, [{E, eqc_gen:bool()} || E <- L0], [X || {X, true} <- L]).
You can’t perform that action at this time.