Skip to content

Instantly share code, notes, and snippets.

@mtnygard
mtnygard / ptable.clj
Created February 12, 2017 04:14
Randomly generate pairs from a table of pairwise weights.
(require [clojure.test.check.generators :as gen])
(defn ptable
[label cols & rows]
(let [ncols (count cols)]
(assert (= 0 (mod (count rows) (inc ncols))))
(mapcat
(fn [[r & vs]]
(map (fn [c v] [v [c r]]) cols vs))
(partition (inc ncols) rows))))
@mtnygard
mtnygard / service.clj
Created November 23, 2016 13:17
Using the not-found-interceptor as a catchall
(ns support.service
(:require [io.pedestal.http :as http]
[io.pedestal.http.route :as route]))
(defn about-page
[request]
{:status 200 :body (format "Clojure %s - served from %s"
(clojure-version)
(route/url-for ::about-page))})

Keybase proof

I hereby claim:

  • I am mtnygard on github.
  • I am mtnygard (https://keybase.io/mtnygard) on keybase.
  • I have a public key ASBwxeoj-3gX6AwhrGHus60trRH4_ZYUdh-up2NGqCu46Qo

To claim this, I am signing this object:

@mtnygard
mtnygard / service-checklist.md
Created September 13, 2016 03:09 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@mtnygard
mtnygard / interceptor.clj
Created August 25, 2016 12:38 — forked from ohpauleez/interceptor.clj
An example of how to make conditional interceptors that enqueue new interceptors
;; Let's start with a simple conditional interceptor that works with functions...
(defn conditional-context
"Given a keyword name and any variable predicate and terminator function pairs,
return an interceptor that will apply the terminator function paired to the first
truthy predicate. Predicates and terminators are both given the context as
the only argument.
If all predicates fail, the original context is returned."
[name-kw & pred-terms]
Verifying that +mtnygard is my blockchain ID. https://onename.com/mtnygard
@mtnygard
mtnygard / gist:06fe9aa8e598f41b61a9
Created February 14, 2015 17:29
Mark Burgess's book stack on Complexity
- Information and the Nature of Reality, Davies and Gregersen
- Swarm Intelligence, Bonabeau, Dorigo, Theraulaz
- Chaos, ed. Arun V. Holden
- Linked, Baraboa
- The Origins of Order, Kauffman
- Investigations, Kauffman
- Emergence, Steven Johnson
- Elements of Information Theory, Cover, Thomas
- The End of Certainty, Prigogine
- Physical Fluid Dynamics, Tritton
@mtnygard
mtnygard / clj-refactor-actions.md
Last active August 29, 2015 14:08
A printable table of refactor actions to help me memorize the keystrokes.
Sequence Action
ad add declaration for current top-level form
ai add import to namespace declaration, then jump back
ap add a dependency to your project depends on refactor-nrepl
ar add require to namespace declaration, then jump back (see optional setup)
au add "use" (ie require refer all) to namespace declaration, then jump back
cc cycle surrounding collection type
ci refactoring between if and if-not
cp cycle privacy of defns and defs
"... the Tracy-Widom distribution and its large deviation tails represent a universal phase transition between weak- and strong-coupling phases."
http://www.simonsfoundation.org/quanta/20141015-at-the-far-ends-of-a-new-universal-law/

Reciprocal Needs in the Employment Relation

We can look at two sides of the management coin: What do the individuals get out of it? And what benefit does the whole system derive from it?

I will disregard any benefits that accrue to managers just by holding the position of managing. Those are just circular logic. Circular logic abounds in discussions of management and hierarchy. For example, consider status reports. It will be said that status reports are necessary so managers know what their employees are working on. It’s