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 | |
struct AsyncAPI { | |
enum AsyncAPIError: Error, LocalizedError { | |
case callDidNotCompleteSynchronously | |
case noErrorAndNoData | |
var errorDescription: String? { | |
switch self { |
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 BaseDelegate: class { | |
func baseMethod() | |
} | |
protocol SecondaryDelegate: BaseDelegate { | |
func secondaryMethod() | |
} | |
protocol TertiaryDelegate: BaseDelegate { | |
func tertiaryMethod() |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>beers_on_wall</key> | |
<dict> | |
<key>NSStringLocalizedFormatKey</key> | |
<string>%#@beers@</string> | |
<key>beers</key> | |
<dict> |
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
//: This is based on Vincent Pradeilles' NSSpain 2018 lightning talk. I tried to find a way around using a | |
//: custom operator for this because I haaaaate custom operators, but everything else I tried just led to | |
//: more callback hell. | |
//: | |
//: Custom `infix` operators allow you to pass the left hand side and right hand side of the operator as | |
//: the first and second parameters of a function. I couldn't figure out how to make a function which did that. | |
//: | |
//: Vincent's original approach is outlined here: | |
//: https://github.com/vincent-pradeilles/slides/blob/master/nsspain-2018-solving-callback-hell-with-good-old-function-composition.pdf | |
//: |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
print("Time Zone Abbreviation: Time Zone Identifier\n") | |
print(TimeZone.abbreviationDictionary.map { "\($0): \($1)" }.sorted().joined(separator: "\n")) | |
print("\n\nKnown Time Zone Identifiers:\n") | |
print(TimeZone.knownTimeZoneIdentifiers.joined(separator: "\n")) | |
let utc = TimeZone(identifier: "UTC")! |
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
#!/bin/bash | |
# http://www.makeuseof.com/tag/siri-voice-mac/ | |
# list all voices: say -v ? "hello world" | |
# US female (Siri) voice: -v "Samantha" | |
# Irish female voice: -v "Moira" | |
# Australian female voice: -v "Karen" | |
# Indian-english voice: -v "Veena" |
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 | |
/** | |
A swift protocol to make any Int enum able to count its cases. | |
Super-useful for making enums to help you deal with sections in tableviews without having to maintain a case for the count of the enum. | |
Originally developed by Logan Wright for Swift 2.0 here: | |
https://gist.github.com/LoganWright/c8a26b1faf538e40f747 | |
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
//Counts the number of commits on the HEAD of the repo. | |
def headCommitCount() { | |
def cmd = "git rev-list HEAD --count" | |
return cmd.execute().text.toInteger() | |
} | |
android { | |
defaultConfig { | |
versionCode headCommitCount() //Auto-increment the version based on how many commits have occurred. | |
versionName "x.x.x (" + versionCode + ")" |
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
/** | |
How to get a method which takes any string enumeration in Swift 2.1. | |
Actually figured out by Carl Hill-Popper, documented by me. | |
*/ | |
import UIKit | |
// 1) Make you some string enums. |
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
/* | |
Fun with NSNumber to integer and unsigned integer conversions! This | |
bit someone trying to use key-value coding to get the average of a | |
given number out of an array of items with an NSUInteger property. | |
The NSNumber which came out of the @avg.value KVC method was of value | |
588.33333333333333333333333333333333333. The person then tried to access | |
this value by calling both average.integerValue and | |
average.unsignedIntegerValue. |
NewerOlder