Skip to content

Instantly share code, notes, and snippets.

View forPaul.txt
1d0
< import AppKit
9a9
> import StoreKit
10a11
> import UIKit
25,35c26,28
< @available(OSX 10.15, *)
< @available(iOS, unavailable)
< @available(tvOS, unavailable)
View Separator2.swift
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()
View retag gitconfig
####
# 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`; \
@erica
erica / FirstAttemptLayers.swift
Created Mar 12, 2020
Breathe Animation Challenge
View FirstAttemptLayers.swift
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)
View AssociatedProjectedValue1.swift
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
View Example.swift
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:
View rawchars.swift
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
View playgroundRender.swift
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
View ModalDetail.swift
import PlaygroundSupport
import SwiftUI
struct LiveView: View {
@State var isPresented = false
var modalPresentation: some View {
NavigationView {
Text("Hello World")
.font(.caption)
View Touch.swift
import PlaygroundSupport
import SwiftUI
extension View {
public func offset(by offset: CGPoint) -> Self.Modified<_OffsetEffect> {
self.offset(x: offset.x, y: offset.y)
}
}
struct LiveView : View {
You can’t perform that action at this time.