Skip to content

Instantly share code, notes, and snippets.

:octocat:
Started work for @alphagov!

Tristram Oaten 0atman

:octocat:
Started work for @alphagov!
Block or report user

Report or block 0atman

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
@0atman
0atman / README.md
Last active Sep 25, 2017
The Testable Documentation Manifesto
View README.md

#! blaze sh

The Testable Documentation Manifesto

One of the problems with tech documentation (api, installation instructions etc) is that they get stale. APIs change, software and plugins alter their interface and commands, and websites go away.

To solve this, I propose we write our documentation in a way that can be executed, or verified.

Luckily, I wrote blaze to execute codeblocks inside of markdown, which means that with a little help from a few common unix tools, we can solve this problem.

View contract.clj
(defn tester [x]
{:pre [(is (even? x))]}
x)
@0atman
0atman / blaze.md
Last active Nov 1, 2017
Blaze is lit. It allows language-agnostic literate-style programming
@0atman
0atman / pexed
Last active Sep 7, 2017
A simple wrapper around `pex`. For self-contained python scripts.
View pexed
#!/usr/bin/env sh
requirements=$1
script=$2
exec pex $requirements -- $script
@0atman
0atman / future.clj
Last active Sep 27, 2017
Hy implamentation of Clojure's awesome `future` call
View future.clj
(import [multiprocessing.pool [ThreadPool]])
(defmacro future [code]
(def t (gensym))
(def pool (ThreadPool :processes 1))
`(do
(def ~t (pool.apply-async (fn [] ~code)))
~t))
View Untitled.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View vis.html
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.20.0/vis.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.20.0/vis.min.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#mynetwork {
width: 600px;
height: 400px;
border: 1px solid lightgray;
View future.clj
(defn return_after_5_secs [message]
(do (Thread/sleep 5000) message))
future = (future return_after_5_secs “hello”)
(realized? future)
(Thread/sleep 5000)
(realized? future)
(println @future)
View concurrent.py
from concurrent.futures import ThreadPoolExecutor
from time import sleep
def return_after_5_secs(message):
sleep(5)
return message
pool = ThreadPoolExecutor(3)
future = pool.submit(return_after_5_secs, ("hello"))
View react.js
class HelloMessage extends React.Component {
render() {
return <div>Hello {this.props.name}</div>;
}
}
ReactDOM.render(<HelloMessage name="John" />, mountNode);
You can’t perform that action at this time.