Skip to content

Instantly share code, notes, and snippets.

AlexanderBollbach / gist:7ccf81c17465caa70a8c751e34853b25
Created Jun 20, 2020
a crazy over the top graph i made to model project types in my drawing app
View gist:7ccf81c17465caa70a8c751e34853b25
//import UIKit
//import ComposableArchitecture
//enum RelationType: String, Hashable, Codable {
// case selected
// case child
// case soloed
//protocol GraphType {
View infiniteMaxWidthInScrollViewBehavior.swift
struct ContentView: View {
let content = ["long word","b","an even longer sentence to display"]
var body: some View {
ScrollView(.horizontal) {
HStack {
ForEach(Array(content.enumerated()), id: \.offset) { e in
Text(e.element).frame(maxWidth: .infinity)
View listSupport.swift
//import Foundation
//import ComposableArchitecture
//protocol Selectable {
// var isSelected: Bool { get set }
//protocol Creatable {
View gist:ce161d7c932bf6ac907f8d1f23428dda
extension ViewStore where State == SomeState, Action == SomeAction {
var displayValue: String {
// do a bunch of querying on viewStore
return ""
func sendAction(with id: Int) -> Void {
// create a
if viewStore.isValid {
View gist:3b2ac696edceb49ab37700d9759fdf07 question: 'ListAction'?
I have been working on an app that has a very complex GUI. Think of a digital synth plugin where there are many levels of
nesting components (faders in envelope banks in presets of a project, etc.). One pattern I observed was that at each level
in the hierarchy I have to operate over some generic ‘element’ as well as manipulate the elements as a group. For this I
defined a ‘ListAction’. It looks roughly like the following:
enum ListAction<Element, ElementAction, ID> {
// … “List level actions”
View gist:b9dea8bd75d56a07c220d6713c2e28d8
enum GQLRequest {
case mutation(NonEmptySet<Mutation>)
case query(NonEmptySet<Query>)
enum Query {
case getCurrentUser(NonEmptySet<User>)
case currentUserPermissions(args: GQLRequestArgs.GetCurrentUserPermissions)
View gist:696f7a88af4b9c568b92c5fa979e022c
protocol APIType {
var currentEnvironment: API.RemoteEnv { get }
func update(environment: API.RemoteEnv)
@discardableResult func perform<T>(_ request: T, complete: @escaping (APIResult<T>) -> Void) -> Cancellable
class API: APIType {
struct Configuration {
typealias AuthenticationHeaders = (() -> [String: String])
View gist:fa99d77ffa5af5bc6d376f76976a67ba
const configuration: ConfigParams = {
appName: 'testApp',
configLocation: 'remote',
profile: 'dev',
configServerName: 'testApp',
logProperties: false,
interval: 60
View gist:2c80d53b5ad1c0ea920757bf1e6d49a5
private func getHttpLog(request: HTTPRequest) -> String {
var result: [String] = []
request.headers.forEach { header in
result.append("key: \(header.key), value: \(header.value)")
result.append(request.body?.string ?? "problem parsing body")
return result.joined(separator: "\n")
View gist:73e60dc00cd3a6b75a6d9bfb29593a59
class AnimatingFramedView: UIView {
var isPaused = false
private var timer: Timer?
private lazy var viewFrameUpdater = RealTimeViewUpdator(delegate: self)
var tick = 0
You can’t perform that action at this time.