Skip to content

Instantly share code, notes, and snippets.

View joe-henke's full-sized avatar
🌶️

Joe Henke joe-henke

🌶️
  • Hover
  • San Rafael
  • 05:22 (UTC -08:00)
View GitHub Profile
@andymatuschak
andymatuschak / States-v3.md
Last active November 14, 2024 18:33
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,

@vasanthk
vasanthk / System Design.md
Last active November 19, 2024 10:54
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@alanzeino
alanzeino / lldb-debugging.md
Last active May 29, 2024 03:18
LLDB debugging with examples

LLDB Debugging Cheat Sheet

Commands

LLDB Commands

LLDB comes with a great set of commands for powerful debugging.

help

Your starting point for anything. Type help to get a list of all commands, plus any user installed ones. Type 'help for more information on a command. Type help to get help for a specific option in a command too.

@jshier
jshier / ResponseSerializer.swift
Last active February 12, 2017 23:06
Custom ResponseSerializer for Alamofire 3
static func CloudFlareResponseSerializer<T: Decodable where T == T.DecodedType>() -> ResponseSerializer<T, CloudFlareError> {
return ResponseSerializer { (request, response, data, error) in
guard error == nil else {
return .Failure(CloudFlareError.NetworkError(error: error!))
}
let JSONResult = Request.JSONResponseSerializer().serializeResponse(request, response, data, nil)
guard case let .Success(responseJSON) = JSONResult else {
return .Failure(CloudFlareError.SerializationError(error: JSONResult.error!))
}
@nicklockwood
nicklockwood / gist:21495c2015fd2dda56cf
Last active August 13, 2020 13:57
Thoughts on Swift 2 Errors

Thoughts on Swift 2 Errors

When Swift was first announced, I was gratified to see that one of the (few) philosophies that it shared with Objective-C was that exceptions should not be used for control flow, only for highlighting fatal programming errors at development time.

So it came as a surprise to me when Swift 2 brought (What appeared to be) traditional exception handling to the language.

Similarly surprised were the functional Swift programmers, who had put their faith in the Haskell-style approach to error handling, where every function returns an enum (or monad, if you like) containing either a valid result or an error. This seemed like a natural fit for Swift, so why did Apple instead opt for a solution originally designed for clumsy imperative languages?

I'm going to cover three things in this post:

@JaviLorbada
JaviLorbada / FRP iOS Learning resources.md
Last active June 17, 2024 06:08
The best FRP iOS resources.

Videos

@joshdholtz
joshdholtz / SwiftGenericFactory.swift
Created October 17, 2014 03:20
Swift Generic Factory
//
// ViewController.swift
// SwiftTest
//
// Created by Josh Holtz on 8/3/14.
// Copyright (c) 2014 Josh Holtz. All rights reserved.
//
import UIKit
@staltz
staltz / introrx.md
Last active November 19, 2024 09:32
The introduction to Reactive Programming you've been missing
@tomasbasham
tomasbasham / UIImage+Scale.m
Last active February 1, 2024 19:04
Scale a UIImage to any given rect keeping the aspect ratio
@implementation UIImage (scale)
/**
* Scales an image to fit within a bounds with a size governed by
* the passed size. Also keeps the aspect ratio.
*
* Switch MIN to MAX for aspect fill instead of fit.
*
* @param newSize the size of the bounds the image must fit within.
* @return a new scaled image.
@jaseemabid
jaseemabid / git tutorials.md
Last active August 26, 2024 02:27 — forked from netroy/git tutorials.md
Awesome git tutorials I am finding here and there