Skip to content

Instantly share code, notes, and snippets.

View msealand's full-sized avatar
⛈️

Michael Sealand msealand

⛈️
  • Boulder Creek, CA
View GitHub Profile

Keybase proof

I hereby claim:

  • I am msealand on github.
  • I am msealand (https://keybase.io/msealand) on keybase.
  • I have a public key whose fingerprint is CC24 794B 721F 482D D29A 4D94 4D1D D4A1 DED6 09FD

To claim this, I am signing this object:

@msealand
msealand / AsyncBlockOperation.h
Last active November 9, 2020 02:52
Asynchronous version of NSBlockOperation
#import <Foundation/Foundation.h>
typedef void(^AsyncBlock)(dispatch_block_t completionHandler);
@interface AsyncBlockOperation : NSOperation
@property (nonatomic, readonly, copy) AsyncBlock block;
+ (instancetype)asyncBlockOperationWithBlock:(AsyncBlock)block;
@msealand
msealand / CGVectorUtilities.swift
Last active September 4, 2019 17:37
Operator overloads to do scalar vector math on CGPoint, CGSize, CGVector.
import CoreGraphics
protocol VectorType {
typealias Element
var xElement: Element { get }
var yElement: Element { get }
class func buildFrom(#x: Element, y: Element) -> Self
@msealand
msealand / RandomCharacter.swift
Created October 28, 2014 02:20
Generate a random character from a range of characters (Unicode safe)
func randomCharacter<T: IntervalType where T.Bound == Character>(inRange range: T) -> Character {
let startScalars = String(range.start).unicodeScalars
let startCode = startScalars[startScalars.startIndex].value
let endScalars = String(range.end).unicodeScalars
let endCode = endScalars[endScalars.startIndex].value
let characterCount = distance(startCode, endCode) + 1
let rndOffset = Int(arc4random_uniform(UInt32(characterCount)))