Skip to content

Instantly share code, notes, and snippets.

@ocrampete16
ocrampete16 / pipeline.py
Created March 5, 2019 00:22
A Python implementation of the Pipeline pattern
class Pipeline:
def __init__(self, value):
self.value = value
self.pipes = []
def through(self, pipe):
self.pipes.append(pipe)
def now(self):
for pipe in self.pipes:
@ocrampete16
ocrampete16 / canvas-mvu.js
Created March 4, 2019 23:59
The Model-View-Update Architecture for use with HTML5 Canvases
class CanvasMvu {
constructor(canvas, model, view, update) {
this.canvas = canvas;
this.model = model;
this.view = view;
this.update = update;
}
get callback() {
return () => {
@ocrampete16
ocrampete16 / pre-commit
Created May 28, 2018 21:58
A pre-commit hook that only lets you commit when your tests pass
#!/bin/sh
git stash --keep-index
git clean --force
make run-tests # for example
tests_passed=$?
git stash pop
exit $tests_passed