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
/// Sectional Sale | |
prefix operator >> {} | |
postfix operator >> {} | |
public prefix func >>(rhs: UInt16) -> UInt16 -> UInt16 { | |
return { lhs in lhs >> rhs } | |
} | |
public postfix func >>(lhs: UInt16) -> UInt16 -> UInt16 { |
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
NSString *safe = self.keys.url.port.stringValue; | |
NSString *unsafe = @"url.port.stringValue"; | |
assert([safe isEqualToString:unsafe]); |
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
// Defines a yet undocumented method to add a warning if super isn't called. | |
#ifndef NS_REQUIRES_SUPER | |
#if __has_attribute(objc_requires_super) | |
#define NS_REQUIRES_SUPER __attribute((objc_requires_super)) | |
#else | |
#define NS_REQUIRES_SUPER | |
#endif | |
#endif | |
@interface UIViewController (SubclassingWarnings) |
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
struct User { | |
let id: Int | |
let name: String | |
let email: String? | |
} | |
extension User: JSONDecodable { | |
static func create(id: Int, name: String, email: String?) -> User { | |
return User(id: id, name: name, email: email) | |
} |
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 Cocoa | |
struct Person { | |
var name: String = "John" | |
var age: Int = 50 | |
var dutch: Bool = false | |
var address: Address? = Address(street: "Market St.") | |
} | |
struct Address { |
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
// uses PriorityQueue from https://github.com/mauriciosantos/Buckets-Swift | |
protocol Pathfinding { | |
typealias Node: Hashable | |
func neighborsFor(node: Node) -> [Node] | |
func costFrom(from: Node, to: Node) -> Int | |
func heuristicFrom(from: Node, to: Node) -> Int | |
} |
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
/** | |
* The examples provided by Facebook are for non-commercial testing and | |
* evaluation purposes only. | |
* | |
* Facebook reserves all rights not expressly granted. | |
* | |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL | |
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
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
// | |
// CollectionViewDataSource.swift | |
// Khan Academy | |
// | |
// Created by Andy Matuschak on 10/14/14. | |
// Copyright (c) 2014 Khan Academy. All rights reserved. | |
// | |
import UIKit |
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
+ (NSAttributedString *)artsyBodyTextAttributedStringFromHTML:(NSString *)HTML withFont:(UIFont *)font | |
{ | |
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; | |
style.lineHeightMultiple = 1.2; | |
style.paragraphSpacing = font.pointSize * .5; | |
NSDictionary *textParams = @{ | |
NSFontAttributeName : font, | |
NSParagraphStyleAttributeName : style, |
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
; Comments start with semicolons. | |
; Clojure is written in "forms", which are just | |
; lists of things inside parentheses, separated by whitespace. | |
; | |
; The clojure reader assumes that the first thing is a | |
; function or macro to call, and the rest are arguments. | |
; | |
; Here's a function that sets the current namespace: | |
(ns test) |
OlderNewer