Skip to content

Instantly share code, notes, and snippets.

One More Time

Alex Artemev bartleby

One More Time
View GitHub Profile
andymatuschak /
Last active Jul 22, 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,

unnamedd / MacEditorTextView.swift
Last active Jul 18, 2021
[SwiftUI] MacEditorTextView - A simple and small NSTextView wrapped by SwiftUI.
View MacEditorTextView.swift
* MacEditorTextView
* Copyright (c) Thiago Holanda 2020-2021
* MIT license
import Combine
import SwiftUI
UHKim / example.ios.yml
Last active Jul 17, 2021
GitHub Action iOS build workflow example
View example.ios.yml
name: Example iOS Build
- development
runs-on: macos-latest
pkuecuekyan / WKWebViewSizeToFit.swift
Last active Jun 4, 2021
Adjust height of WKWebView frame based on scrollHeight of the webView's content
View WKWebViewSizeToFit.swift
// Since the WKWebView has no sizeToFit() method, increase the frame height of the webView to
// match the height of the content's scrollHeight
// The WKWebView's `navigationDelegate` property needs to be set for the delegate method to be called
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
if webView.isLoading == false {
webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { [weak self] (result, error) in
if let height = result as? CGFloat {
ha1f / CIFilter+Extension.swift
Last active Apr 2, 2021
View CIFilter+Extension.swift
// Created by はるふ on 2017/12/11.
// Copyright © 2017年 ha1f. All rights reserved.
import Foundation
import CoreImage
import AVFoundation
extension CIFilter {
mteece /
Last active Mar 13, 2021
List of NSTimeZone Abbreviations and Names (iOS 9.3.1)

NSTimeZone - Timezone Abbreviations ADT = "America/Halifax"; AKDT = "America/Juneau"; AKST = "America/Juneau"; ART = "America/Argentina/Buenos_Aires"; AST = "America/Halifax"; BDT = "Asia/Dhaka"; BRST = "America/Sao_Paulo"; BRT = "America/Sao_Paulo"; BST = "Europe/London";

ilyapuchka / StickyLayout.swift
Last active Feb 17, 2021
Really sticky collection view layout
View StickyLayout.swift
// The issue with sectionHeadersPinToVisibleBounds and sectionFootersPinToVisibleBounds is that they do not pin
// first header and last footer when bouncing. This layout subclass fixes that.
class StickyLayout: UICollectionViewFlowLayout {
override init() {
self.sectionFootersPinToVisibleBounds = true
self.sectionHeadersPinToVisibleBounds = true
View Cluster.swift
class Number /* class cluser */ {
class Int8: Number {
var value: Swift.Int8
init(_ value: Swift.Int8) { self.value = value }
class Int: Number {
var value: Swift.Int
init(_ value: Swift.Int) { self.value = value }
cmoulton / Custom HTTP Headers with Swift and Alamofire.swift
Last active Mar 26, 2020
Custom HTTP Headers with Swift 3 or 4 and Alamofire 4.0-4.7: See for explanations
View Custom HTTP Headers with Swift and Alamofire.swift
// MARK: - Adding a header to a single request
func doRequestWithHeaders1() {
let headers: HTTPHeaders = [
"X-Mashape-Key": MY_API_KEY,
"Accept": "application/json"
Alamofire.request("", headers: headers)
.responseJSON { response in
shazron / gist:943736
Created Apr 27, 2011
About XCode 4 Project Template (How To Create Custom Project Template)
View gist:943736
XCode 4 Projects and Files Template Folder: /Developer/Library/Xcode/Templates
/Developer/Library/Xcode/Templates/Project Templates/Base/Other/Empty.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Base/Base.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Mac Base.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Command Line Tool.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Cocoa Application.xctemplate