This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <objc/runtime.h> | |
@interface UIViewController (SEUIIntentTarget_SWIZZLE) | |
- (UIResponder *)SEUI_originalNextResponder; | |
@end | |
@interface SEUIIntentTarget () | |
@property (nonatomic, weak, nullable) UIViewController *owningViewController; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import StacMan; | |
@import JRSwizzle; | |
NS_INLINE NSURL *TransformURLForForTier(NSURL *URL, SEAPIContext *context) { | |
if (context.mobileRoot || context.apiRoot) { | |
NSMutableString *computedUrl = [URL.absoluteString mutableCopy]; | |
if (context.mobileRoot) { | |
[computedUrl replaceOccurrencesOfString:@"https://mobile.stackexchange.com" withString:context.mobileRoot options:NSCaseInsensitiveSearch range:NSMakeRange(0, [computedUrl length])]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/swift | |
// Because sometimes you don't want to crop. | |
// USAGE: aspect-grow RATIO FILES... | |
// aspect-grow 4:6 *.jpg | |
// | |
// Places all files in an output directory relative to their location, so | |
// aspect-grow 4:6 *.jpg creates a folder "output" in this directory but | |
// aspect-grow 4:6 a/b.jpg and b/c.jpg creates folders a/output and b/output. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Security | |
import Foundation | |
// MARK: - Redefining boilerplate code | |
func SecKeychainOpen(path:String) -> SecKeychainRef? { | |
var keychain:Unmanaged<SecKeychainRef>? = nil | |
if SecKeychainOpen((path as NSString).UTF8String, &keychain) == errSecSuccess { | |
return keychain?.takeRetainedValue() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// USAGE: | |
// Call RestorationDefender.printViewControllerClassesThatAreProbablyNotRestorable() to print a list of view controllers that will probably not return from state restoration. | |
// Call RestorationDefender.crashWhenViewControllersDoNotImplementStateRestoration() to crash your app when a view controller appears without setting restorationIdentifier and restorationClass. | |
// Call RestorationDefender.shoutWhenViewControllersDoNotImplementStateRestoration() to print a big message when a view controller appears without setting restorationIdentifier and restorationClass. | |
import Foundation | |
private func objc_getClassList() -> [AnyClass] { | |
let expectedClassCount = objc_getClassList(nil, 0) | |
var allClasses = UnsafeMutablePointer<AnyClass?>.alloc(Int(expectedClassCount)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/swift | |
// TL;DR: Skip to line 183. | |
// To run as a script, run with /usr/bin/swift or chmod +x. | |
// To run as a playground, comment out the first line and `mkdir -p "~/Documents/Shared Playground Data"`. | |
import Foundation | |
let stdin = NSFileHandle.fileHandleWithStandardInput() | |
let stdout = NSFileHandle.fileHandleWithStandardOutput() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<meta name="viewport" content="initial-scale=1, maximum-scale=1"> | |
<script src="http://code.jquery.com/jquery-2.1.3.min.js"></script> | |
<style> | |
div { | |
position: absolute; | |
background-color:green; | |
left: 100px; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/swift | |
import Foundation | |
let url = NSURL(string: "http://not-a-real-host")! | |
let request = NSURLRequest(URL: url) | |
var response:NSURLResponse? = nil | |
var error:NSError? = nil | |
NSURLConnection.sendSynchronousRequest(request, returningResponse: &response, error: &error) |