View Heap.swift
This file contains 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
final class Heap<T> { | |
typealias Comparator = (T,T) -> Bool | |
var elements: [T] | |
let priority: Comparator | |
init(elements: [T], priority: @escaping Comparator) { | |
self.priority = priority | |
self.elements = elements |
View invisibleCharacter.swift
This file contains 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
// These little spaces are invisible in Xcode. Copy them around and watch everything break! | |
func foo(arg: Int) { | |
print("\(arg)") | |
} |
View immutable.swift
This file contains 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
protocol ImmutableCopy { | |
associatedtype InitializerTuple | |
var lastInitParams: AnyInitializerParams<InitializerTuple> { get } | |
func copy(from: (InitializerTuple) -> Self, applying: (inout InitializerTuple) -> Void) -> Self | |
} | |
extension ImmutableCopy { | |
func copy(from: (InitializerTuple) -> Self, applying: (inout InitializerTuple) -> Void) -> Self { | |
var values = lastInitParams.values | |
applying(&values) |
View buck_targets_to_test.swift
This file contains 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 Foundation | |
func run(command: String, wait: Bool = true) -> String? { | |
let task = Process() | |
task.launchPath = "/bin/bash" | |
task.arguments = ["-c", command] | |
let pipe = Pipe() | |
task.standardOutput = pipe | |
task.launch() | |
guard wait else { |
View ios_header_remover.swift
This file contains 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 Foundation | |
func findFiles(rootPath: String, suffix: String, ignoreDirs: Bool = true) -> [String]? { | |
var result = [String]() | |
let fileManager = FileManager.default | |
if let paths = fileManager.subpaths(atPath: rootPath) { | |
let swiftPaths = paths.filter { $0.hasSuffix(suffix) } | |
for path in swiftPaths { | |
var isDir : ObjCBool = false | |
let fullPath = (rootPath as NSString).appendingPathComponent(path) |
View Shortcuts app decoded shortcut HTML
This file contains 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
<html> | |
<head> | |
<title>Take Picture</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | |
<meta name="apple-mobile-web-app-capable" content="yes"> | |
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> | |
<link rel="apple-touch-icon-precomposed" href="http:/localhost:58844/webclips/images/Take%2520Picture/icon.png"> | |
<link rel="apple-touch-startup-image" media="(orientation: landscape)" href="http:/localhost:58844/webclips/images/Take%2520Picture/landscape-launch.png"/> | |
<link rel="apple-touch-startup-image" media="(orientation: portrait)" href="http:/localhost:58844/webclips/images/Take%2520Picture/portrait-launch.png"/> |
View DerivedConformanceCaseIterable+first.cpp
This file contains 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
ValueDecl *DerivedConformance::deriveCaseIterable(ValueDecl *requirement) { | |
// Conformance can't be synthesized in an extension. | |
if (checkAndDiagnoseDisallowedContext(requirement)) | |
return nullptr; | |
// Check that we can actually derive CaseIterable for this type. | |
if (!canDeriveConformance(Nominal)) | |
return nullptr; | |
Type returnTy; |
View ViewCode7.swift
This file contains 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
class CustomViewController<CustomView: UIView>: UIViewController { | |
var customView: CustomView { | |
return view as! CustomView | |
} | |
override func loadView() { | |
view = CustomView() | |
} | |
} |
View ViewCode6.swift
This file contains 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
final class MyViewController: UIViewController, HasCustomView { | |
typealias CustomView = MyView | |
override func loadView() { | |
let customView = CustomView() | |
customView.delegate = self | |
view = customView | |
} | |
override func viewDidLoad() { |
View ViewCode5.swift
This file contains 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
/// The HasCustomView protocol defines a customView property for UIViewControllers to be used in exchange of the regular view property. | |
/// In order for this to work, you have to provide a custom view to your UIViewController at the loadView() method. | |
public protocol HasCustomView { | |
associatedtype CustomView: UIView | |
} | |
extension HasCustomView where Self: UIViewController { | |
/// The UIViewController's custom view. | |
public var customView: CustomView { | |
guard let customView = view as? CustomView else { |
NewerOlder