Skip to content

Instantly share code, notes, and snippets.

@NilStack
NilStack / symbolicatecrash.pl
Created March 7, 2019 06:25
symbolicatecrash.pl
#!/usr/bin/perl -w
#
# This script parses a crashdump file and attempts to resolve addresses into function names.
#
# It finds symbol-rich binaries by:
# a) searching in Spotlight to find .dSYM files by UUID, then finding the executable from there.
# That finds the symbols for binaries that a developer has built with "DWARF with dSYM File".
# b) searching in various SDK directories.
#
# Copyright (c) 2008-2011 Apple Inc. All Rights Reserved.
@NilStack
NilStack / UICollectionViewFlowLayout+DelegateAccess.swift
Created April 21, 2018 02:46 — forked from danielctull/UICollectionViewFlowLayout+DelegateAccess.swift
Wraps the six UICollectionViewFlowLayout delegate methods and their equivalent properties using functional programming techniques, so that values are easier to retrieve. Full details at: http://danieltull.co.uk/blog/2018/04/13/simplifying-uicollectionviewflowlayout-delegate-method-usage-with-functional-programming/
extension UICollectionViewFlowLayout {
typealias DelegateMethod<Key, Value> = ((UICollectionView, UICollectionViewLayout, Key) -> Value)
private var delegate: UICollectionViewDelegateFlowLayout? {
return collectionView?.delegate as? UICollectionViewDelegateFlowLayout
}
func retrieve<Key, Value>(
@NilStack
NilStack / ..build-protobuf-3.0.0.md
Created April 7, 2018 13:38 — forked from petewarden/..build-protobuf-3.0.0.md
Script used to build Google Protobuf 3.0.0 for use with Xcode 7 / iOS 9. Builds all supported architectures and produces a universal binary static library.

Google Protobuf 3.0.1 - Mac OS X and iOS Support

The script in this gist will help you buid the Google Protobuf library for use with Mac OS X and iOS. Other methods (such as homebrew or direct compilation) have issues that prevent their use. The libraries built by this script are universal and support all iOS device architectures including the simulator.

This gist was adapted from the original at https://gist.github.com/BennettSmith/7150245, and updated to deal with Xcode 7 and iOS 9, and download protobuf version 3.0.0.

@NilStack
NilStack / KeyboardNotification.swift
Created August 10, 2017 07:42 — forked from kristopherjohnson/KeyboardNotification.swift
Swift convenience wrapper for the userInfo values associated with a UIKeyboard notification
import UIKit
/// Wrapper for the NSNotification userInfo values associated with a keyboard notification.
///
/// It provides properties that retrieve userInfo dictionary values with these keys:
///
/// - UIKeyboardFrameBeginUserInfoKey
/// - UIKeyboardFrameEndUserInfoKey
/// - UIKeyboardAnimationDurationUserInfoKey
/// - UIKeyboardAnimationCurveUserInfoKey
@NilStack
NilStack / UIViewPropertyAnimatorExample1.swift
Last active March 10, 2020 04:02
UIViewPropertyAnimator example
import UIKit
import PlaygroundSupport
class AnimatorExampleViewController: UIViewController {
let startButton = UIButton()
let pauseButton = UIButton()
let stopButton = UIButton()
let resetButton = UIButton()
@NilStack
NilStack / SpeechRecognitionRecordedAudio.swift
Created September 22, 2016 06:31
Speech Recognition with recorded audio
let recognizer = SFSpeechRecognizer()
let request = SFSpeechURLRecognitionRequest(url: audioFileURL)
recognizer?.recognitionTask(with: request, resultHandler: { (result, error) in
print (result?.bestTranscription.formattedString)
})
@NilStack
NilStack / QuickExample.swift
Created September 20, 2016 07:51
a simple and complete example in Quick
import Quick
import Nimble
@testable import MyGreatApp
class LoginViewControllerSpec: QuickSpec {
override func spec() {
var viewController: LoginViewController!
beforeEach {
@NilStack
NilStack / SFSpeechRecognizerrequestAuthorization
Created September 19, 2016 08:45
SFSpeechRecognizer requestAuthorization
SFSpeechRecognizer.requestAuthorization { authStatus in
switch authStatus {
case .authorized:
print("authorized")
case .denied:
print("denied")
case .restricted:
print("restricted")
@NilStack
NilStack / QuickTemplate
Created September 18, 2016 07:12
Quick Template
import Quick
import Nimble
class QuickBasic: QuickSpec {
override func spec() {
}
}
@NilStack
NilStack / UIDeviceHardware.h
Created August 7, 2016 01:45 — forked from Jaybles/UIDeviceHardware.h
UIDeviceHardware - Determine iOS device being used
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;