次のSwift 2.2コードをSwift 3でビルドできるようにする。
//
// SequenceTests.swift
//
import XCTest
class SequenceTests: XCTestCase {
// The hash algorithm is founded on http://opensource.apple.com//source/CF/CF-1153.18/CFString.c | |
import Foundation | |
let first16Char = repeatElement("f", count: 32) | |
let middle16Char = repeatElement("m", count: 32) | |
let last16Char = repeatElement("l", count: 32) | |
let a = (first16Char + ["ab"] + middle16Char + ["ab"] + last16Char).joined() | |
let b = (first16Char + ["bc"] + middle16Char + ["bc"] + last16Char).joined() | |
a == b // false | |
// Foundation |
#!/usr/bin/expect -f | |
# | |
# otpauthFromVIPAccess.exp | |
# | |
# Generate otpauth scheme url from Symantec VIP Access. | |
# Usage: | |
# ./otpauthFromVIPAccess.exp [v] | |
# If the "v" argument (or any argument) is specified, verbose output | |
# will be produced on stderr. The otpauth url will be output on stdout. | |
# |
git config user.signingkey <secret key id> | |
git config gpg.program /path/to/gpg-batch-notty.sh | |
git config commit.gpgsign true |
// | |
// Collection+movingAverage.swift | |
// | |
// inspired by https://gist.github.com/hirohitokato/5bfc5836480d68074135820d73c04794 | |
import Foundation | |
public protocol ArithmeticType: Comparable, IntegerLiteralConvertible { | |
func +(lhs: Self, rhs: Self) -> Self |
import Foundation | |
/// A reference type that provides a better default representation than the class name | |
public protocol DefaultReflectable: Streamable {} | |
/// A default implementation that enables class members to display their values | |
extension DefaultReflectable { | |
/// Constructs a better representation using reflection | |
internal func DefaultDescription<T>(instance: T) -> String { | |
let mirror = Mirror(reflecting: instance) |
import Foundation | |
extension String { | |
func withStaticString(@noescape f: StaticString -> Void) { | |
withCString { | |
let rawPointer = $0._rawValue | |
let byteSize = lengthOfBytesUsingEncoding(NSUTF8StringEncoding)._builtinWordValue | |
let isASCII = true._getBuiltinLogicValue() | |
let staticString = StaticString(_builtinStringLiteral: rawPointer, byteSize: byteSize, isASCII: isASCII) | |
f(staticString) |
git submodule update --init --recursive
stores gitdir
in full path into .git
of nested submodules.
So, working directory is not portable to another directory.
On following example, Carthage/Checkouts/Quick/Externals/Nimble/
is nested submodule and Carthage/Checkouts/Quick/Externals/Nimble/.git
contains full path.
➜ 15:34:01 git clone https://github.com/Carthage/Commandant.git
Cloning into 'Commandant'...
remote: Counting objects: 891, done.
remote: Compressing objects: 100% (93/93), done.
sudo install_name_tool -add_rpath @executable_path/../lib/swift/macosx /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-03-16-a.xctoolchain/usr/bin/swift-build | |
sudo install_name_tool -add_rpath @executable_path/../lib/swift/macosx /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-03-16-a.xctoolchain/usr/bin/swift-test |
protocol Pokemon { | |
typealias PokemonType | |
func attack(move: PokemonType) | |
} | |
class Pikachu: Pokemon { | |
func attack(move: Int) { | |
print("pika") | |
} | |
} |