Skip to content

Instantly share code, notes, and snippets.

@mtnygard
mtnygard / 00_readme
Created December 20, 2012 16:30
DEVS state machine
core.clj - DEVS state machine implementation. This ns provides construction functions as well as the generic evolver. A state machine is simply data about the allowed states, allowed inputs, and actions to trigger on transitions.
core-test.clj - Tests for DEVS
echo.clj - A sample usage. Illustrates construction and application of the state machine.
@mtnygard
mtnygard / query.clj
Created February 8, 2013 22:19
Use Datomic queries as a source for RxJava pipes.
(ns rxjava-datomic.query
(:require [datomic.api :as d])
(:use [clojure.repl :only [pst]])
(:import [rx Observable]
datomic.Peer))
(defn query [qry & inputs]
(Observable/toObservable
(Peer/q qry (object-array inputs))))
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px;
color: #333;
}
@mtnygard
mtnygard / gist:5615250
Created May 20, 2013 20:29
Query for all data types supported in Datomic.
user> (require '[datomic.api :as d])
nil
user> (def conn (d/connect (doto "datomic:mem://temp" d/create-database)))
#'user/conn
user> (d/q '[:find ?type ?doc :where
[_ :db.install/valueType ?t]
[?t :db/ident ?type]
[?t :db/doc ?doc]]
(d/db conn))
#{[:db.type/long "Fixed integer value type. Same semantics as a Java long: 64 bits wide, two's complement binary representation."]
@mtnygard
mtnygard / jenkins.json
Last active October 14, 2019 09:35
Packer.io template for a Jenkins server
{
"builders": [{
"type": "amazon-ebs",
"access_key": "",
"secret_key": "",
"region": "us-east-1",
"source_ami": "ami-de0d9eb7",
"instance_type": "m1.large",
"ssh_username": "ubuntu",
"ami_name": "packer-jenkins {{.CreateTime}}"
@mtnygard
mtnygard / First build, fails in units tests on operators
Created August 31, 2013 16:47
RxJava Non-deterministic build at commit [6a7ee812c7](https://github.com/Netflix/RxJava/commit/6a7ee812c75234ed01350b2fa168223f2d79c62e). All these transcripts are from a single shell, executed one after the other.
RxJava master mn › ./gradlew clean build
The TaskContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
:language-adaptors:clean
:rxjava-contrib:clean
:rxjava-core:clean
:language-adaptors:rxjava-clojure:clean UP-TO-DATE
:language-adaptors:rxjava-groovy:clean UP-TO-DATE
:language-adaptors:rxjava-scala:clean UP-TO-DATE
:rxjava-contrib:rxjava-android:clean UP-TO-DATE
:rxjava-contrib:rxjava-swing:clean UP-TO-DATE
@mtnygard
mtnygard / gist:7555463
Last active May 22, 2017 10:59
The limitations of test

From Out of the Tar Pit:

The key problem with testing is that a test (of any kind) that uses one particular set of inputs tells you nothing at all about the behaviour of the system or component when it is given a different set of inputs. The huge number of different possible inputs usually rules out the possibility of testing them all, hence the unavoidable concern with testing will always be — have you performed the right tests?. The only certain answer you will ever get to this question is an answer in the negative — when the system breaks.

This is a strong argument for some form of generative, simulation, or property-based testing.

@mtnygard
mtnygard / sm.clj
Created January 7, 2014 17:48
A really, really minimal state machine with validity checking.
(ns sm)
(defn satisfied?
[machine input [txn-state txn-input guard & _]]
(and (= (:state machine) txn-state) (= input txn-input) (if guard (guard machine input) true)))
(defn evolve
[m i]
(let [[_ _ _ next & actions] (first (filter #(satisfied? m i %) (:transitions m)))
_ (println actions)

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

"... 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/