An exceptionally handsome way to track your Stack Overflow badges.
Created by Adam & Stephanie Sharp.
A Dashing widget that tracks your progress toward unearned badges on Stack Overflow.
// | |
// Category on NSArray to allow subscripting via an NSIndexPath. | |
// | |
// Adam Sharp | |
// May 27, 2013 | |
// | |
// Given this array: | |
// | |
// NSArray *matrix = @[ | |
// @[ @1, @2 ], |
import Dispatch | |
/// Wraps some `Base` type so that all method calls become | |
/// "message sends", e.g., `async { $0.foo() }` or `sync { $0.bar() }`. | |
public final class Actor<Base> { | |
private var instance: Base | |
private let queue: DispatchQueue | |
public init(_ instance: Base, target: DispatchQueue? = nil) { | |
self.instance = instance |
func + <S: SequenceType, E where S.Generator.Element == E> (lhs: S, rhs: S) -> GeneratorOf<E> { | |
var (g, h) = (lhs.generate(), rhs.generate()) | |
return GeneratorOf { | |
g.next() ?? h.next() | |
} | |
} |
struct BitMask<T: FixedWidthInteger>: RandomAccessCollection { | |
typealias SubSequence = BitMask<T> | |
var rawValue: T { | |
var rawValue: T = 0 | |
for bit in self { | |
rawValue |= bit | |
} | |
return rawValue | |
} |
import Foundation | |
let text = """ | |
Hello | |
World | |
""" | |
extension String { | |
var lines: AnySequence<Substring> { | |
let string = self |
An exceptionally handsome way to track your Stack Overflow badges.
Created by Adam & Stephanie Sharp.
A Dashing widget that tracks your progress toward unearned badges on Stack Overflow.
import UIKit | |
/// For a view controller that has no content of its own, implement like so: | |
/// | |
/// extension RootViewController: ContentViewEmbedding { | |
/// var contentView: UIView! { | |
/// return view | |
/// } | |
/// } | |
protocol ContentViewEmbedding { |
struct User { | |
var name: String | |
} | |
let currentUser = MutableProperty(User(name: "Foo")) | |
currentUser[\.name] <~ nameTextField.reactive.textValues |
// Copyright (c) 2019–20 Adam Sharp and thoughtbot, inc. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: | |
// | |
// The above copyright notice and this permission notice shall be included in |
import Foundation | |
class Channel<Message> { | |
private enum State { | |
case empty | |
case readyToReceive | |
case full(Message) | |
} | |
private let condition: NSCondition |