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 | |
class APIClient { | |
// 1 - Error enum | |
enum APIClientError: Error { | |
case dataTaskFailed(Error) | |
case noHTTPURLResponse | |
case badHTTPStatusCode(HTTPURLResponse) | |
case noData |
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
div > .vimiumHintMarker { | |
/* linkhint boxes */ | |
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#565756), | |
color-stop(100%,#242524)); | |
border: 1px solid #e4e5e4; | |
opacity: 1.0; | |
text-shadow: none !important; | |
} | |
div > .vimiumHintMarker span { |
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
// | |
// UIColor+PXExtensions.h | |
// Creates UIColor from hex string. "#" prefix is optional. Supports 3 and 6 hex digits. | |
// Originally from http://pixelchild.com.au/post/12785987198/how-to-convert-a-html-hex-string-into-uicolor-with | |
// But that link seems to be broken. | |
// Revived by Thongchai Kolyutsakul (21 May 2015). | |
// | |
// USAGE: UIColor *mycolor = [UIColor pxColorWithHexValue:@"#BADA55"]; | |
// UIColor *mycolor = [UIColor pxColorWithHexValue:@"FFFFFF"]; | |
// UIColor *mycolor = [UIColor pxColorWithHexValue:@"1AD"]; |
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 | |
import UIKit | |
// From an example view hierarchy... | |
// 1 -> 2 -> 3 -> 4 -> 5 | |
// | | |
// ---> 6 | |
// Find the least common ancestor of 2 views. | |
// Input |
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
find /Applications -name "*.app" -user old-user -maxdepth 1 | tr \\n \\0 | xargs -0 sudo chown -R $USER |
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 | |
// Allows defining CodingKey from String | |
struct DynamicCodingKey: CodingKey { | |
var intValue: Int? | |
var stringValue: String | |
init?(intValue: Int) { | |
assertionFailure("Not implemented") | |
return nil |
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 | |
public extension Array { | |
// Iterate through all elements in pair tuples | |
// e.g. [1, 2, 3, 4].allPairs = [(1, 2), (2, 3), (3, 4)] | |
var allPairs: [(Element, Element)] { | |
var array: [(Element, Element)] = [] | |
for i in 0..<self.count - 1 { | |
array.append((self[i], self[i+1])) | |
} |
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 UIKit | |
public extension UIColor { | |
convenience init(hex: String) { | |
let r, g, b, a: CGFloat | |
var hex = hex | |
if hex.hasPrefix("#") { hex = String(hex.dropFirst()) } | |
if hex.count == 6 { |
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 | |
import XcodeKit | |
class SourceEditorCommand: NSObject, XCSourceEditorCommand { | |
// Reverses code on selected lines | |
func perform(with invocation: XCSourceEditorCommandInvocation, completionHandler: @escaping (Error?) -> Void ) -> Void { | |
let lines = invocation.buffer.lines as? [String] ?? [] |
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
/** Converts NSData to a hexadecimal string. */ | |
@interface NSData (NSData_hexadecimalString) | |
/** Changes NSData object to a hex string. | |
@returns hexadecimal string of NSData. Empty string if data is empty.*/ | |
- (NSString *)hexadecimalString; | |
@end | |
@implementation NSData (NSData_hexadecimalString) |