Skip to content

Instantly share code, notes, and snippets.


Daryle Walker CTMacUser

  • Connecticut, USA
View GitHub Profile
jjrscott / BidirectionalCollection+RegularExpressions.swift
Created Jul 15, 2020
Reimplementation of Brian Kernighan's Regular Expression Matcher on BidirectionalCollection
View BidirectionalCollection+RegularExpressions.swift
// RegularExpression.swift
// RegularExpressions
// Created by John Scott on 15/07/2020.
// Original matching implementation Brian Kernighan :
// Swift port Ben Cohen :
import Foundation
rxwei /
Last active Jan 28, 2020
Upstreaming Swift AutoDiff

Upstreaming Swift AutoDiff

Author: Richard Wei ( on behalf of the Swift for TensorFlow team

Last updated: October 2, 2019


The differentiable programming feature (AutoDiff) has been incubated in the 'tensorflow' branch of apple/swift since December 2017 and released as part of the Swift for TensorFlow toolchains. The Differentiable Programming Mega-Proposal, which serves as a manifesto, received general positive feedback from the community, but there is a long way between receiving conceptual approval and obtaining Swift Evolution approval of such a large feature. We would like to merge the pieces into the 'master' branch under a gate to further development and bake the feature on master, just like Apple develops its major features

reckenrode / json.swift
Created Jun 23, 2017
Decoding arbitrary JSON with the new Decoder in Swift 4
View json.swift
enum JSON: Decodable {
case bool(Bool)
case double(Double)
case string(String)
indirect case array([JSON])
indirect case dictionary([String: JSON])
init(from decoder: Decoder) throws {
if let container = try? decoder.container(keyedBy: JSONCodingKeys.self) {
self = JSON(from: container)
Gankra /
Last active Apr 3, 2019
Swift Ownership Manifesto TL;DR

Swift Ownership Manifesto TL;DR

Most of the manifesto is background and detailed definitions -- if you're confused or want details, read the manifesto!

Note also that manifestos aren't complete proposals -- syntax and details may change!

One piece of background: inout is kinda complicated because it can be used on computed properties -- foo(&val.x) might be sugar for


Value Subtypes and Generalized Enums, a manifesto

The goal of this document is to provide a comprehensive view of what value subtyping might look like in Swift and demonstrate how generalized enums play a significant role in this future.

Note: All syntax used in this document that is not currently valid Swift syntax is only intended to serve the purpose of demonstrating ideas and to serve as a point of reference for future proposals. The intent is not to propose that this exact syntax be used.

Acknowledgement: some of the ideas in this document have been inspired by Niko Matsakis' blog post exploring similar ideas in the context of Rust:


tomduckering / ValueTransformer.swift
Last active Oct 25, 2018 — forked from gonzalezreal/ValueTransformer.swift
Type safe NSValueTransformer
View ValueTransformer.swift
import Foundation
private class BasicValueTransformer: ValueTransformer {
let transform: (AnyObject?) -> (AnyObject?)
init(transform: @escaping (AnyObject?) -> (AnyObject?)) {
self.transform = transform
// MARK: NSValueTransformer
santisbon /
Last active Oct 22, 2020
Deploying from Git branches adds flexibility. Bring your feature branch up to date with master and deploy it to make sure everything works. If everything looks good the branch can be merged. Otherwise, you can deploy your master branch to return production to its stable state.

Updating a feature branch

First we'll update your local master branch. Go to your local project and check out the branch you want to merge into (your local master branch)

$ git checkout master

Fetch the remote, bringing the branches and their commits from the remote repository. You can use the -p, --prune option to delete any remote-tracking references that no longer exist in the remote. Commits to master will be stored in a local branch, remotes/origin/master

View with.swift
// @discardableResult to be added
// @noescape needs to move to type annotation
// needs to add _ for item
public func with<T>(item: T, @noescape update: (inout T) throws -> Void) rethrows -> T {
var this = item; try update(&this); return this
mattshepherd / apple help book example.txt
Last active Jan 12, 2020
To support the table of contents button in the OS X Help Book app you need to implement the following code. This isn't documented anywhere but I found it in Apple's own help files and tested it to work. I believe it only works in the more recent versions of OS X, so you if your app supports really old versions you might want to check it.
View apple help book example.txt
//disable TOC button
//enable TOC button
//If you call this on window load it will flash active for a brief second and then disable again.
//Call if after a delay of 250ms and is works fine
//Not sure what the second variable does yet, but passing false works fine
window.HelpViewer.showTOCButton( true, false, function() {
//do something to toggle TOC in your webpage
View example1.swift
import UIKit
import XCPlayground
class ViewController: UIViewController {
func action() { print("Bing!") }
override func viewDidLoad() {
view.backgroundColor = .whiteColor()
You can’t perform that action at this time.