Skip to content

Instantly share code, notes, and snippets.

View craiggrummitt's full-sized avatar

Craig Grummitt craiggrummitt

View GitHub Profile
@proxpero
proxpero / Permutations.swift
Last active September 18, 2023 13:17
Generate the permutations of a Swift array.
//: Permutations
// based on https://www.objc.io/blog/2014/12/08/functional-snippet-10-permutations/
// but updated for Swift 2.0 (Xcode 7.0)
extension Array {
func decompose() -> (Generator.Element, [Generator.Element])? {
guard let x = first else { return nil }
return (x, Array(self[1..<count]))
}
}
@TonnyXu
TonnyXu / UIKit_System_Notifications.h
Created January 18, 2011 01:37
All the notifications predefined by UIKit framework. Apple should provide this but they don't. So, take it if you need it.
// UIApplication.h
UIApplicationDidEnterBackgroundNotification __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0);
UIApplicationWillEnterForegroundNotification __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0);
UIApplicationDidFinishLaunchingNotification;
UIApplicationDidBecomeActiveNotification;
UIApplicationWillResignActiveNotification;
UIApplicationDidReceiveMemoryWarningNotification;
UIApplicationWillTerminateNotification;
UIApplicationSignificantTimeChangeNotification;
UIApplicationWillChangeStatusBarOrientationNotification; // userInfo contains NSNumber with new orientation