Skip to content

Instantly share code, notes, and snippets.

View mstultz's full-sized avatar
🍥

Mark Stultz mstultz

🍥
View GitHub Profile
@funami
funami / gist:2407027
Created April 17, 2012 15:50
Upload file to S3 with AFNetworking
#import "AFNetworking.h"
- (IBAction)uploadTest:(id)sender {
NSURL *url = [NSURL URLWithString:@"https://xxx.s3-ap-northeast-1.amazonaws.com/"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
NSData *imageData = UIImagePNGRepresentation([UIImage imageNamed:@"194-note-2.png"]);
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
@"xxxxx/videos/XXXXW",@"key",
@"XXXXXXXX",@"AWSAccessKeyId",
@pgodino
pgodino / GPUImageMovie.h
Created October 2, 2012 15:06
Play audio with movie
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import "GPUImageOpenGLESContext.h"
#import "GPUImageOutput.h"
#import "TPCircularBuffer.h"
#ifndef max
#define max( a, b ) ( ((a) > (b)) ? (a) : (b) )
#endif
@turowicz
turowicz / swift-json-class.md
Last active February 21, 2017 07:00
Apple Swift strong type object serialization to JSON
@austinzheng
austinzheng / main.swift
Last active March 7, 2016 20:41
Anonymous class experiment in Swift
import Foundation
protocol SomeDelegateProtocol : class {
func firstFunc() -> String
func secondFunc() -> Bool
func thirdFunc() -> Self
}
class MyClass {
weak var delegate : SomeDelegateProtocol?
@alexbosworth
alexbosworth / KeychainService.swift
Last active January 5, 2021 08:26
Swift Keychain Class
import UIKit
import Security
let serviceIdentifier = "com.company"
let accessGroup = "com.company.app"
let kSecClassValue = kSecClass as NSString
let kSecAttrAccountValue = kSecAttrAccount as NSString
let kSecValueDataValue = kSecValueData as NSString
let kSecClassGenericPasswordValue = kSecClassGenericPassword as NSString
//
// AppDelegate.swift
// TypedTableViewControllers
//
// Created by Chris Eidhof on 23/03/15.
// Copyright (c) 2015 Unsigned Integer. All rights reserved.
//
import UIKit
@jonathan-beebe
jonathan-beebe / vundle_swift_vim_instructions.md
Last active November 30, 2021 16:24
Using Apple’s Swift vim plugin with Vundle

Source of original vim config: https://github.com/apple/swift/tree/master/utils/vim

# use `svn checkout…` to grab just the subfolder from github
svn checkout https://github.com/apple/swift/trunk/utils/vim
# rename to something a bit more specific
mv vim vim-swift
cd vim-swift
rm -rf .svn
# init git
@Nyx0uf
Nyx0uf / NYXAVCEncoder.swift
Created February 3, 2016 10:35
Hardware accelerated GIF to MP4 converter in Swift using VideoToolbox
import VideoToolbox
import AVFoundation
private var __canHWAVC: Bool = false
private var __tokenHWAVC: dispatch_once_t = 0
public protocol NYXAVCEncoderDelegate : class
{
func didEncodeFrame(frame: CMSampleBuffer)
func didFailToEncodeFrame()
@andymatuschak
andymatuschak / States-v3.md
Last active June 12, 2024 04:17
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 / 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,