Skip to content

Instantly share code, notes, and snippets.

erica / 00-dragndrop.swift
Last active Jun 28, 2020
Building an OSX Drag and Drop Playground: Throw the dragndrop.swift into shared Sources and then test out the examples in individual playgrounds. Make sure the assistant is open and set to the timeline. I prefer vertical assistant stacking for this.
View 00-dragndrop.swift
import Cocoa
// Support Foundation calls on String
public extension String { public var ns: NSString {return self as NSString} }
/// Custom Labeled Playground-Based Drag-and-Drop window
public class DropView: NSTextField {
// Default action handler
public var handler: ([String]) -> Void = { paths in Swift.print(paths) }
View c.swift
import UIKit
extension UIBezierPath {
func traverseElements() -> NSArray {
var array: [AnyObject] = []
withUnsafeMutablePointer(&array) {
arrayPtr -> Void in
View forPaul.txt
< import AppKit
> import StoreKit
> import UIKit
< @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()
import sys
from enum import *
import cozmo
from cozmo.util import degrees
from Triggers import *
# Log Error
def error(message):
print("*********************ERROR:", message)
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`; \

Introducing with to the Standard Library


This proposal introduces a with function to the standard library. This function

View Swift

Adding Method Cascades

  • Proposal: TBD
  • Author(s): Erica Sadun
  • Status: TBD
  • Review manager: TBD


Method cascades offer a method-based counterpart to functional chaining. In functional chaining, partial results pass from one step to the next. In cascades, object scope is maintained through a series of sequential calls. Both approaches support fluent interfaces, providing readable streamlined code.

View CrossPlatformDefines.swift
Erica Sadun,
Cross Platform Defines
Apple Platforms Only
Will update to #if canImport() when available
You can’t perform that action at this time.