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
// known-good: Swift 3 | |
import UIKit | |
/// for a UIView that can be populated via `configure` | |
protocol ConfigurableView : class { | |
associatedtype Value | |
func configure(_ value:Value) | |
} | |
/// for a UICollectionViewCell wrapping a UIView |
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
/** | |
Generic CollectionViewCell, which can be specialized to wrap a UIView. | |
To use this, you can simply define a typealias like so: | |
``` | |
class FooView : UIVIew { /* ... */ } | |
typealias FooCell = WrappedCollectionViewCell<FooView> | |
``` |
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 UIKit | |
// known-good: Xcode 8.2.1 | |
/** | |
UIImageView subclass which works with Auto Layout to try | |
to maintain the same aspect ratio as the image it displays. | |
This is unlike the usual behavior of UIImageView, where the |
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
// known-good Xcode 8.2.1 | |
extension URL | |
{ | |
/** | |
Returns the data from a URI with the "data:" scheme, which includes the optional "base64" annotation, and which has a mediatype that is encoded in ASCII. As described in https://tools.ietf.org/html/rfc2397. | |
*/ | |
var asData:Data? | |
{ | |
guard | |
let scheme = self.scheme, scheme == "data", |
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 | |
// machine, version, release, nodename, sysname | |
extension utsname : CustomStringConvertible { | |
static var `default`:utsname { | |
var x = utsname() | |
uname(&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
// known-good: Xcode 8.2.1, Swift 3, 2017-02-08 | |
/** | |
Draws a circle, centered in the view, with the specified radius | |
*/ | |
class CircleView: UIView | |
{ | |
// API | |
var circleRadius:CGFloat = 15 { | |
didSet { self.setNeedsLayout() } |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<!-- iOS 10, macOS Sierra, and friends bring a new logging subsystem that's | |
supposed to scale from the kernel, up to frameworks, and up to apps. It defaults | |
to a more regimented, privacy-focused approach that large apps and complex | |
systems need. | |
It, along with Activity Tracing introduced in iOS 8 and macOS Yosemite and the | |
Console app in macOS Sierra, hope to help you graduate from caveman debugging to |
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 | |
command -v carthage >/dev/null 2>&1 || { echo >&2 "I require carthage but it's not installed. Aborting."; exit 1; } | |
carthage update --no-build | |
# A policy proposal: | |
# | |
# We use the "carthage" tool only to download the source code of | |
# third-party libraries that we depend on. |
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
// known-good Swift3 | |
extension String { | |
/// Performs in-place replacement of first occurence of a substring | |
mutating func replaceFirstOccurence(of query:String, with replacement:String) { | |
guard let firstRange = self.range(of: query) | |
else { return } | |
self.replaceSubrange(firstRange, with: replacement) | |
} | |
} |
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
// Swift 3, macos/Linux | |
#if os(Linux) | |
import Glibc | |
#else | |
import Darwin | |
#endif | |
class RandomByteGenerator { | |
private let f = fopen("/dev/urandom","r") |