Author: Chris Lattner
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 | |
let intJson = #"{ "inUse": 1, "name": "Daiki Matsudate", "twitter": "d_date", "stars": 99999, "occupation": null}"# | |
let boolJson = #"{ "inUse": true, "name": "Daiki Matsudate", "twitter": "d_date", "stars": 99999, "occupation": null}"# | |
protocol Inherits { | |
associatedtype SuperType | |
var `super`: SuperType { get } | |
} |
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 Optional { | |
public mutating func ensure(_ f: () throws -> Wrapped) rethrows -> Wrapped { | |
if let x = self { | |
return x | |
} | |
let x = try f() | |
self = x | |
return x | |
} |
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 Array { | |
public mutating func remove(where: (Element) -> Bool) { | |
while let index = self.index(where: `where`) { | |
remove(at: index) | |
} | |
} | |
public func removed(where: (Element) -> Bool) -> [Element] { | |
var copy = self | |
copy.remove(where: `where`) |
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 Unicode.Scalar { | |
var width: UInt32 { | |
let code = self.value | |
if (code >= 0 && code <= 128) { | |
return 1 | |
} else { | |
return 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
extension String { | |
func split(_ size: Int) -> [String] { | |
return stride(from: 0, to: self.count, by: size).map { i -> String in | |
let startIndex = self.index(self.startIndex, offsetBy: i) | |
let endIndex = self.index(startIndex, offsetBy: size, limitedBy: self.endIndex) ?? self.endIndex | |
return String(self[startIndex..<endIndex]) | |
} | |
} | |
} | |
print("あけましておめでとうございます。今年もどうぞよろしくお願いします。".split(5)) |
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
// | |
// Database.swift | |
// Model | |
// | |
// Created by mono on 2017/10/14. | |
// Copyright © 2017 Masayuki Ono All rights reserved. | |
// | |
import Foundation | |
import FirebaseCore |
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 java.io.File | |
import java.io.InputStream | |
import java.io.OutputStream | |
import java.io.Reader | |
enum class Token { | |
NEXT, PREV, INC, DEC, GET, PUT, LOOP, JUMP, ROOT | |
} | |
interface Parser { |
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 | |
enum PPAP { | |
case Start | |
indirect case Pen(PPAP), Apple(PPAP), Pineapple(PPAP), Finish(PPAP) | |
var output: String { | |
switch self { | |
case .Start: return "ピッピッピコ ピコ太郎〜♪" | |
case .Pen(let p): return "\(p.output)\nI have a ✏️" | |
case .Apple(let p): return "\(p.output)\nI have an 🍎" |
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
#!/bin/sh | |
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal | |
# make sure the output directory exists | |
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" | |
# Step 1. Build Device and Simulator versions | |
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build |
NewerOlder