- Proposal: SE-nnnnnnnn
- Authors: Erica Sadun, Chris Lattner
- Review Manager: TBD
- Status: Awaiting implementation
- Proposal: SE-nnnnnnnn
- Authors: Chris Lattner, Erica Sadun
- Review Manager: TBD
- Status: Awaiting implementation
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
1d0 | |
< import AppKit | |
9a9 | |
> import StoreKit | |
10a11 | |
> import UIKit | |
25,35c26,28 | |
< @available(OSX 10.15, *) | |
< @available(iOS, unavailable) | |
< @available(tvOS, unavailable) |
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
extension String { | |
/// Returns a new string with the camel-case-based words of this string | |
/// split by the specified separator. | |
/// | |
/// Examples: | |
/// | |
/// "myProperty".convertedToSnakeCase() | |
/// // my_property | |
/// "myURLProperty".convertedToSnakeCase() |
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
#### | |
# Retag | |
retag = "!f(){ name=`git tag`; git tag -d \"$name\"; echo "Retagged $name"; remote=`git remote -v`; \ | |
if [ \"$remote\" != \"\" ]; then git push origin --delete \"$name\"; fi; \ | |
git tag \"$name\"; \ | |
if [ \"$remote\" != \"\" ]; then git push --tags; else echo "No remote"; fi; };f" | |
untag = "!f(){ name=`git tag`; git tag -d \"$name\"; remote=`git remote -v`; \ | |
if [ \"$remote\" != \"\" ]; then git push origin --delete \"$name\"; \ | |
else echo "No remote"; fi; };f" | |
tagit = "!f(){ git tag \"$@\"; echo "Tagged $name"; remote=`git remote -v`; \ |
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 | |
import PlaygroundSupport | |
extension Int { | |
var cg: CGFloat { return CGFloat(self) } | |
} | |
// Canvas size | |
let extent: CGFloat = 200 | |
let rect = CGRect(x: 0, y: 0, width: extent, height: extent) |
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 Cocoa | |
@propertyWrapper | |
public struct AssociatedValues<Value, Projection> { | |
private var value: Value | |
public var wrappedValue: Value { value } | |
public var projectedValue: [String: Projection] = [:] | |
public init(wrappedValue value: Value) { | |
self.value = value |
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 | |
do { | |
// Note: scalar.utf8 is only available in 10.15 | |
while let byte = try RawMode.getByte() { | |
let scalar = UnicodeScalar(byte) | |
switch scalar.isASCII { | |
case true: | |
print(Character(UnicodeScalar(byte)), ":", byte) | |
case false: |
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 | |
import Darwin | |
/// Raw mode handling for character-by-character input in term | |
/// | |
/// Via [this stack overflow post][post] | |
/// | |
/// [post]: https://stackoverflow.com/questions/49748507/listening-to-stdin-in-swift | |
public enum RawMode { | |
/// Error states for raw mode entry |
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 PlaygroundSupport | |
import SwiftUI | |
extension UIView { | |
var renderedImage: UIImage { | |
let image = UIGraphicsImageRenderer(size: self.bounds.size).image { context in | |
UIColor.lightGray.set(); UIRectFill(bounds) | |
context.cgContext.setAlpha(0.75) | |
self.layer.render(in: context.cgContext) | |
} | |
return image |