Skip to content

Instantly share code, notes, and snippets.

View mstultz's full-sized avatar
🍥

Mark Stultz mstultz

🍥
View GitHub Profile
@mstultz
mstultz / TextSize.swift
Created February 22, 2020 19:41 — forked from gnou/TextSize.swift
Calculate height of some text when width is fixed
public struct TextSize {
fileprivate struct CacheEntry: Hashable {
let text: String
let font: UIFont
let width: CGFloat
let insets: UIEdgeInsets
fileprivate var hashValue: Int {
return text.hashValue ^ Int(width) ^ Int(insets.top) ^ Int(insets.left) ^ Int(insets.bottom) ^ Int(insets.right)
@mstultz
mstultz / lattice_take_home.md
Created July 31, 2019 05:15 — forked from andrewhubbs/lattice_take_home.md
Lattice Take Home Exercise

Lattice Take Home Exercise

First off, thank you for taking the time to interview with the Lattice team. We know your creativity and time are valuable and we're excited you are willing to share some of it with us.

Project

We would like you to build a small web app for finding information about all of your favorite movies using the The Movie Database API.

Minimum Feature Set

import UIKit
public enum Bit: Int {
case zero
case one
}
extension Bit {
func inverted() -> Bit {
return self == .zero ? .one : .zero
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
let kCMBlockBufferNoErr                        = 0
let kCMBlockBufferStructureAllocationFailedErr = -12700
let kCMBlockBufferBlockAllocationFailedErr     = -12701
let kCMBlockBufferBadCustomBlockSourceErr      = -12702
let kCMBlockBufferBadOffsetParameterErr        = -12703
let kCMBlockBufferBadLengthParameterErr        = -12704
let kCMBlockBufferBadPointerParameterErr       = -12705
let kCMBlockBufferEmptyBBufErr                 = -12706
let kCMBlockBufferUnallocatedBlockErr          = -12707
@mstultz
mstultz / CoreAudio.md
Last active December 28, 2016 01:02
Coreaudio-api mailing list
                 __________
 [Bus 1: Mic]-->|          |-->[Bus 1: App]
                | RemoteIO |
 [Bus 0: App]-->|          |-->[Bus 0: Speaker]
                 ----------
let status = AudioUnitSetProperty(audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, UInt32(bus), &enableIO, UInt32(MemoryLayout.size))
@mstultz
mstultz / States-v3.md
Created November 11, 2016 00:13 — forked from andymatuschak/States-v3.md
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,

@mstultz
mstultz / RecordRemoteIO.m
Created May 5, 2015 16:43
Naive recording of 16384 frames of the Remote IO input
//
// RecordRemoteIO.m
// AudioTest
//
// Created by Mark Stultz on 5/5/15.
// Copyright (c) 2015 Mark Stultz. All rights reserved.
//
#import <AudioToolbox/AudioToolbox.h>
#import "RecordRemoteIO.h"