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
| // XCTestCase+Stub.swift | |
| import Foundation | |
| import XCTest | |
| import Mockingjay | |
| extension XCTestCase { | |
| /// Web API のリクエストをテストプロジェクトの json でスタブする | |
| /// | |
| /// - Parameters: |
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
| print("start") | |
| # update version numbers | |
| current_ver_str = '1.0.0' # 現在のバージョン番号 | |
| new_ver_str = '1.1.0' # 新しいバージョン番号 | |
| # plist file names | |
| file_names = [ | |
| 'Foo/SupportingFiles/Info.plist', | |
| 'Foo/SupportingFiles/InfoStaging.plist', |
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
| class Solution: | |
| def twoSum(self, nums, target): | |
| """ | |
| :type nums: List[int] | |
| :type target: int | |
| :rtype: List[int] | |
| """ | |
| for i, num in enumerate(nums): | |
| for j, num2 in enumerate(nums): | |
| if i == j: |
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
| private extension MyTests { | |
| private func setLocaleAsJP() { | |
| let original = class_getClassMethod(NSLocale.self, #selector(getter: NSLocale.current))! | |
| let swizzled = class_getClassMethod(NSLocale.self, #selector(NSLocale.myCurrentLocale))! | |
| method_exchangeImplementations(original, swizzled) | |
| } | |
| } | |
| // https://stackoverflow.com/questions/31065859/how-can-i-change-the-locale-on-the-xcode-playground | |
| fileprivate extension NSLocale { |
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 Foundation | |
| struct Book: Codable { | |
| let title: String | |
| let author: String | |
| } | |
| let KeyForUserDefaults = "myKey" | |
| func save(_ books: [Book]) { |
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
| OVERVIEW: Swift compiler | |
| USAGE: swiftc [options] <inputs> | |
| MODES: | |
| -dump-ast Parse and type-check input file(s) and dump AST(s) | |
| -dump-parse Parse input file(s) and dump AST(s) | |
| -dump-scope-maps <expanded-or-list-of-line:column> | |
| Parse and type-check input file(s) and dump the scope map(s) | |
| -dump-type-refinement-contexts |
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 Foundation | |
| // https://developer.apple.com/documentation/foundation/nscomparisonresult | |
| let currentVersion = "0.0.2" | |
| let latestVersion1 = "0.0.3" | |
| let latestVersion2 = "0.0.21" | |
| let latestVersion3 = "0.1.0" | |
| let latestVersion4 = "1.0.0" | |
| let latestVersion5 = "0.0.2" |
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
| #lang racket | |
| (define (average x y) | |
| (/ (+ x y) 2)) | |
| (define (improve guess x) | |
| (average guess (/ x guess))) | |
| (define (sqrt-iter guess x) | |
| (if (good-enough? guess x) | |
| guess |
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 Foundation | |
| import PromiseKit | |
| struct YoRepository { | |
| func fetchDataWithPromise() -> Promise<String> { | |
| return Promise { seal in | |
| DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .milliseconds(500)) { | |
| guard true else { | |
| // failure | |
| seal.reject(MyError.unknown) |
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
| #lang racket | |
| (define (sum_of_square a b c) | |
| (cond ((< a b) (< a c) (+ (* b b) (* c c))) | |
| ((< b c) (< b a) (+ (* a a) (* c c))) | |
| (else (+ (* a a) (* b b))) | |
| ) | |
| ) | |
| (sum_of_square 3 4 5) ;41 | |
| (sum_of_square 8 4 5) ;89 |