Skip to content

Instantly share code, notes, and snippets.


Nathan Borror nathanborror

View GitHub Profile
d-srd / FunctionBuilderTesting.swift
Created Jul 10, 2019
testing the new Swift function builders for creating a simple routing system
View FunctionBuilderTesting.swift
// RouteBuilder.swift
// RouteBuilder
// Created by Dino on 09/07/2019.
// Copyright © 2019 Dino Srdoc. All rights reserved.
import Foundation
Philmod / google-container-kubernetes.js
Last active Nov 26, 2018
Deploy a new image from Google Cloud Container Builder to Kubernetes, using Google Cloud Functions.
View google-container-kubernetes.js
const async = require('async');
const google = require('googleapis');
const k8s = require('kubernetes-client');
const container = google.container('v1');
const PROJECT_ID = 'node-example-gke';
const ZONE = 'us-east1-b';
const CLUSTER_ID = 'node-example-cluster';
const NAMESPACE = 'default';
View gist:fbdd4885b8cb37aea3e0433dcac32544
_viewControllerFlags (struct ?): {
appearState (b2): 0
isEditing (b1): NO
isPerformingModalTransition (b1): NO
hidesBottomBarWhenPushed (b1): NO
autoresizesArchivedViewToFullSize (b1): NO
viewLoadedFromControllerNib (b1): NO
isRootViewController (b1): NO
customizesForPresentationInPopover (b1): NO
isSuspended (b1): NO
andymatuschak /
Last active Jan 25, 2021
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

MrAlek / hamburger.swift
Created Dec 6, 2015
Example of how to use presentation, animation & interaction controllers w/ custom segues to create a slide-in modal menu which partially covers presenting view.
View hamburger.swift
import UIKit
enum Direction {
case Left, Right, Up, Down
var pointVector: CGPoint {
switch self {
case Left: return CGPoint(x: -1, y: 0)
case Right: return CGPoint(x: 1, y: 0)
case Up: return CGPoint(x: 0, y: -1)