I hereby claim:
- I am jtbandes on github.
- I am jtbandes (https://keybase.io/jtbandes) on keybase.
- I have a public key whose fingerprint is 916E DA3E 8754 7C0B 173E D8E3 A6BB C78B 72E6 00C6
To claim this, I am signing this object:
#if os(iOS) | |
import UIKit | |
#else | |
import AppKit | |
#endif | |
/// A set of constraints prepared from a visual format string, in the style of | |
/// `NSLayoutConstraint.constraintsWithVisualFormat()`, with the additional ability | |
/// to supply views and metrics in a string interpolation. | |
/// |
// Battery logger | |
// Jacob Bandes-Storch | |
// April 22, 2015 | |
import Foundation | |
import IOKit | |
func write(s: String, to file: UnsafeMutablePointer<FILE>) |
I hereby claim:
To claim this, I am signing this object:
@import Foundation; | |
NS_ASSUME_NONNULL_BEGIN | |
@interface Function<__contravariant InType, __covariant OutType> : NSObject | |
{ | |
// interestingly, this does work here (though OutType & InType are not available in the @implementation) | |
OutType (^_block)(InType); | |
} |
import Darwin | |
enum Timebase { | |
private static let timebase: mach_timebase_info_data_t = { | |
var data = mach_timebase_info_data_t() | |
let ret = withUnsafeMutablePointer(&data, mach_timebase_info) | |
assert(ret == KERN_SUCCESS) | |
return data | |
}() | |
// Single-struct version. | |
// This seems to work just as well as having a custom generator struct. | |
// I'm not sure if there are other (performance?) implications, however. | |
struct PrefixSequence<T> : SequenceType | |
{ | |
let base: AnySequence<T> | |
let maxLength: Int | |
init<S : SequenceType where S.Generator.Element == T>(_ base: S, _ maxLength: Int) { |
//: Convenience functions/extension on top of GCD. | |
import Dispatch | |
var MainQueue: dispatch_queue_t { return dispatch_get_main_queue() } | |
func GlobalQueue(qos: dispatch_qos_class_t = .Default) -> dispatch_queue_t | |
{ | |
return dispatch_get_global_queue(qos, 0) | |
} |
// please... don't do this | |
import Foundation | |
class F: NSObject | |
{ | |
@objc func foo() { | |
print("hi") | |
} | |
} |
// Much safer! Notice that `iteration` stops increasing after the initial terms are produced. | |
// Thanks @oisdk for pointing this out. | |
public struct RecurrenceRelation<Element>: SequenceType, GeneratorType | |
{ | |
private let recurrence: (T: [Element], n: Int) -> Element | |
private var storage: [Element] | |
/// - Parameter initialTerms: The first terms of the sequence. | |
/// The `count` of this array is the **order** of the recurrence. |