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 Foundation | |
import PlaygroundSupport | |
enum URLResult { | |
case response(Data, URLResponse) | |
case error(Error, Data?, URLResponse?) | |
} | |
extension URLSession { | |
@discardableResult |
// Here is a usage example. Refer to ImagePicker.swift below for the implementation! | |
// 1. Easily configure the picker | |
let cameraPicker = ImagePicker(sourceType: .camera) | |
let cropPicker = ImagePicker(sourceType: .photoLibrary, allowsEditing: true) | |
// Automatically includes both kUTTypeImage and kUTTypeLivePhoto | |
let livePhotoPicker = ImagePicker(sourceType: .photoLibrary, mediaTypes: [.livePhotos]) | |
// 2. Use the picker |
// Prints out all the unicode scalars in a Foundation CharacterSet. | |
// | |
// Compile: swiftc -O scalars.swift | |
// Run: ./scalars <character set name> | |
import Foundation | |
extension UnicodeScalar { | |
static var allScalars: AnySequence<UnicodeScalar> { | |
let numbers = sequence(first: 0, next: { $0 + 1 }) |
extension UIImage { | |
enum AspectOrientation { | |
case portrait | |
case square | |
case landscape | |
} | |
var aspectRatio: CGFloat { | |
return size.aspectRatio | |
} |
import Foundation | |
class Channel<Message> { | |
private enum State { | |
case empty | |
case readyToReceive | |
case full(Message) | |
} | |
private let condition: NSCondition |
// 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 |
struct User { | |
var name: String | |
} | |
let currentUser = MutableProperty(User(name: "Foo")) | |
currentUser[\.name] <~ nameTextField.reactive.textValues |
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 { |
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 Foundation | |
let text = """ | |
Hello | |
World | |
""" | |
extension String { | |
var lines: AnySequence<Substring> { | |
let string = self |