Skip to content

Instantly share code, notes, and snippets.

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 15:58
Python implementation of matlab's `bwmorph` function for the operations:`thin`, `spur`, `bracnhes`, and `endpoints`
"""
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 March 4, 2018 05:19
instaparse parser for prometheus text format exporter (text version 0.0.4)
(* 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 *)
(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))
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 September 8, 2016 17:56
Notebook illustrating a bug in joblib
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
0
1
2
3
4
5
6
7
8
9
@bmabey
bmabey / Bayesian Update.ipynb
Created October 30, 2014 02:54
A tutorial/lab for learning about bayesian updating using IPython Notebook
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 August 29, 2015 14:06
sublist generator for clojure test.check... which has better shrinking properites?
;; 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]).