Skip to content

Instantly share code, notes, and snippets.

1d0
< import AppKit
9a9
> import StoreKit
10a11
> import UIKit
25,35c26,28
< @available(OSX 10.15, *)
< @available(iOS, unavailable)
< @available(tvOS, unavailable)
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()
####
# 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 March 12, 2020 22:10
Breathe Animation Challenge
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)
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
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:
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
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