#Every Single Option Under The Sun
- optimization level options
- automatic crashing options
- debug info options
- swift internal options
- swift debug/development internal options
- linker-specific options
- mode options
#! /bin/sh | |
# usage: <shellscript> [--osx] typename | |
if [ "$1" = "--osx" ] ; then | |
echo ":print_module $2" | xcrun swift -deprecated-integrated-repl | |
else | |
sdk_path=$(echo `xcrun --show-sdk-path` | sed 's#MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk#iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk#') | |
echo ":print_module $1" | xcrun swift -deprecated-integrated-repl -sdk "$sdk_path" | |
fi |
#!/bin/bash | |
pbpaste | pygmentize -O"style=tango, fontface=Menlo" -f rtf -l $1 | pbcopy |
import string | |
import uuid | |
alphabet = string.digits + string.ascii_letters | |
def base62_encode(n): | |
ret = '' | |
while n > 0: | |
ret = alphabet[n % 62] + ret | |
n /= 62 |
protocol Calendar { | |
typealias Unit: BidirectionalIndexType | |
typealias Era: Unit | |
typealias Year: Unit | |
typealias Month: Unit | |
typealias Week: Unit | |
typealias Day: Unit | |
typealias Weekday: Unit | |
typealias Hour: Unit |
import Foundation | |
protocol GQLNodeArgument {} | |
extension String: GQLNodeArgument {} | |
extension NSNumber: GQLNodeArgument {} | |
class GQLNode: StringLiteralConvertible, ArrayLiteralConvertible, Printable, DebugPrintable { | |
let name: String? |
#!/usr/bin/xcrun swift | |
import Cocoa | |
import ObjectiveC | |
// Pretend to be Finder | |
extension Bundle { var __bundleIdentifier: String? { return "com.apple.finder" } } | |
guard let bundleClass : AnyClass = NSClassFromString("NSBundle") | |
else { fatalError("Unable to fetch NSBundle class") } | |
let id1 = class_getInstanceMethod(bundleClass, #selector(getter: Bundle.bundleIdentifier)) | |
let id2 = class_getInstanceMethod(bundleClass, #selector(getter: Bundle.__bundleIdentifier)) |
/* | |
* We've defined "traits" by which we can type an integer that are characteristic of its value. | |
* These traits can even be subtraits of other traits (like both positive and negative being nonzero). | |
* | |
* We can use these traits in the type signatures of functions to indicate what trait will be returned | |
* as a function of the passed-in traits. | |
* | |
* Even cooler, we can specify properties of the traits such that we can runtime-verify the correctness | |
* of these labels (in case a function was improperly annotated, for example). | |
*/ |
#Every Single Option Under The Sun
import Cocoa | |
struct Person { | |
var name: String = "John" | |
var age: Int = 50 | |
var dutch: Bool = false | |
var address: Address? = Address(street: "Market St.") | |
} | |
struct Address { |
// | |
// ArrayDiff.swift | |
// | |
// Created by Frank A. Krueger on 6/30/15. | |
// Copyright © 2015 Krueger Systems, Inc. All rights reserved. | |
// License: MIT http://opensource.org/licenses/MIT | |
// | |
import Foundation |