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
| extension String { | |
| static let phoneDetector = NSDataDetector(types: NSTextCheckingType.PhoneNumber.rawValue, error: nil)! | |
| func stringByFormattingPhoneNumbers() -> String { | |
| var mutableString = self | |
| String.phoneDetector.enumerateMatchesInString(self, options: NSMatchingOptions.allZeros, range: NSRange(location: 0, length: count(self))) { result, flags, stop in | |
| if let | |
| range = self.rangeFromNSRange(result.range), | |
| phoneNumber = result.phoneNumber.flatMap(PhoneManager.sanitizedPhoneNumber) { | |
| mutableString.replaceRange(range, with: PhoneManager.formattedPhoneNumber(phoneNumber)) | |
| } |
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
| protocol KindaEquatable { | |
| func ~==(lhs: Self, rhs: Self) -> Bool | |
| } | |
| infix operator ~!= { associativity left precedence 140 } | |
| func ~!=<T where T: KindaEquatable>(lhs: T, rhs: T) -> Bool { | |
| return !(lhs ~== rhs) | |
| } | |
| // MARK: - String |
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
| extension UIView { | |
| func constraintsEqualToSuperview(_ edgeInsets: UIEdgeInsets = UIEdgeInsets.zero, priority: UILayoutPriority = 1000) -> [NSLayoutConstraint] { | |
| self.translatesAutoresizingMaskIntoConstraints = false | |
| var constraints = [NSLayoutConstraint]() | |
| if let superview = self.superview { | |
| constraints.append(self.constraining(.leading, .equal, to: superview, constant: edgeInsets.left, priority: priority)) | |
| constraints.append(self.constraining(.trailing, .equal, to: superview, constant: -edgeInsets.right, priority: priority)) | |
| constraints.append(self.constraining(.top, .equal, to: superview, constant: edgeInsets.top, priority: priority)) | |
| constraints.append(self.constraining(.bottom, .equal, to: superview, constant: -edgeInsets.bottom, priority: priority)) | |
| } |
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
| static func systemLogs(count: Int = 30) -> [LogEntry] { | |
| let q = asl_new(UInt32(ASL_TYPE_QUERY)) | |
| var logs = [LogEntry]() | |
| let r = asl_search(nil, q) | |
| var m = asl_next(r) | |
| let keysNeeded = [ASL_KEY_MSG, ASL_KEY_TIME, ASL_KEY_LEVEL] | |
| while logs.count < count && m != nil { | |
| var logDict = [String: String]() | |
| for key in keysNeeded { | |
| if let val = String.fromCString(asl_get(m, key)) { |
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
| static func systemLogs() -> [[String: String]] { | |
| let q = asl_new(UInt32(ASL_TYPE_QUERY)) | |
| var logs = [[String: String]]() | |
| let r = asl_search(nil, q) | |
| var m = asl_next(r) | |
| while m != nil { | |
| var logDict = [String: String]() | |
| var i: UInt32 = 0 | |
| while true { | |
| if let key = String.fromCString(asl_key(m, i)) { |
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
| \documentclass{article} | |
| % Change "article" to "report" to get rid of page number on title page | |
| \usepackage{amsmath,amsfonts,amsthm,amssymb} | |
| \usepackage{setspace} | |
| \usepackage{fancyhdr} | |
| \usepackage{lastpage} | |
| \usepackage{extramarks} | |
| \usepackage{chngpage} | |
| \usepackage{soul} | |
| \usepackage[usenames,dvipsnames]{color} |
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
| global _main | |
| bits 64 | |
| default rel | |
| section .text | |
| _main: | |
| mov r8, array | |
| add byte [r8], 8 | |
| loop_0: | |
| cmp byte [r8], 0 | |
| je loop_0_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
| #include <stdio.h> | |
| char mem[30000]; | |
| char *p = mem; | |
| int main() { | |
| p += 1; | |
| *p += 10; | |
| p += 3; | |
| *p += 1; | |
| p += 1; | |
| *p += 1; |
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
| harlan@nietzsche ~/D/C/S/grmustache-example> swift build | |
| Cloning Packages/GRMustache.swift | |
| Compiling Swift Module 'MustacheTVOSTests' (1 sources) | |
| Compiling Swift Module 'DemoApps' (7 sources) | |
| Compiling Swift Module 'Mustache' (32 sources) | |
| Compiling Swift Module 'MustacheTests' (44 sources) | |
| <unknown>:0: error: filename "AppDelegate.swift" used twice: '/Users/harlan/Documents/Code/Swift/grmustache-example/Packages/GRMustache.swift-0.12.0/DemoApps/MustacheDemoiOS/MustacheDemoiOS/AppDelegate.swift' and '/Users/harlan/Documents/Code/Swift/grmustache-example/Packages/GRMustache.swift-0.12.0/DemoApps/MustacheDemoiOS7/MustacheDemoiOS7/AppDelegate.swift' | |
| <unknown>:0: note: filenames are used to distinguish private declarations with the same name | |
| <unknown>:0: error: filename "ViewController.swift" used twice: '/Users/harlan/Documents/Code/Swift/grmustache-example/Packages/GRMustache.swift-0.12.0/DemoApps/MustacheDemoiOS/MustacheDemoiOS/ViewController.swift' and '/Users/harlan/Documents/Code/Swift/grmustache-example/Pac |
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
| Building the standard library for: swift-stdlib-macosx-x86_64 | |
| Running Swift tests for: check-swift-macosx-x86_64 | |
| cmark: using standard linker | |
| ++ cmake_config_opt cmark | |
| ++ product=cmark | |
| ++ [[ Unix Makefiles == \X\c\o\d\e ]] | |
| + /Applications/CMake.app/Contents/bin/cmake --build /Users/harlan/Documents/Code/Swift/swift/build/Unix_Makefiles-DebugAssert/cmark-macosx-x86_64 -- -j8 all | |
| [ 93%] Built target cmark | |
| [ 93%] Built target libcmark |