Skip to content

Instantly share code, notes, and snippets.

Avatar

Stan Stadelman sstadelman

  • Livermore, CA
View GitHub Profile
@sstadelman
sstadelman / String+RegEx.swift
Created Jul 12, 2020
String + Lookahead capture
View String+RegEx.swift
extension String {
var lookaheadCapture: String {
#"\s?\#(self)\s+(?<\#(self)>(\S++))"#
}
}
@sstadelman
sstadelman / String+RegEx.swift
Created Jul 12, 2020
String + Lookahead capture
View String+RegEx.swift
extension String {
var lookaheadCapture: String {
#"\s?\#(self)\s+(?<\#(self)>(\S++))"#
}
}
@sstadelman
sstadelman / git-check-status.sh
Last active Feb 26, 2020
Check status of nested repositories
View git-check-status.sh
for f in *; do
if [ -d ${f} ]; then
cd $(echo $f)
echo $(pwd)
for g in *; do
if [ -d ${g} ]; then
# Will not run if no directories are available
cd $(echo $g)
echo $(pwd) >> ../../git-check-status-output.txt
View bootstrap_swift_environment.sh
brew install cmake ninja
brew install sccache
mkdir swift-source
cd swift-source
git clone --branch swift-5.1.5-RELEASE git@github.com:apple/swift.git
./swift/utils/update-checkout --clone-with-ssh
# ./swift/utils/update-checkout --tag swift-5.1.5-RELEASE
# sccache --start-server
./swift/utils/build-script --clean --xcode --release-debuginfo
./swift/utils/build-script --ios --release-debuginfo
@sstadelman
sstadelman / CodableEnum.swift
Created Nov 19, 2019
Example of Codable enum
View CodableEnum.swift
enum QuicklinkBinding: Codable {
case icon(String)
case title(String)
case description(String)
case action(Action)
enum CodingKeys: CodingKey {
case icon, title, description, action
}
@sstadelman
sstadelman / MustacheRegex.swift
Created Nov 19, 2019
Matcher to find mustache placeholder keys and replacement ranges
View MustacheRegex.swift
extension Array where Element == NSRange {
func maxRange() -> Int {
return self.reduce(0) { (prev, next) in
let maxNext = NSMaxRange(next)
return Swift.max(prev, maxNext)
}
}
}
extension String {
View gist:18ee4374b7e9b3f03727afd9706fe978
brew install cmake ninja
mkdir swift-source
cd swift-source
git clone git@github.com:apple/swift.git
./swift/utils/update-checkout --clone-with-ssh
cd swift
utils/build-script --release-debuginfo
cd ..
alias st=/Users/stan/github/swift-source/build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/bin/sourcekitd-test
View ArabicCharacterSet.swift
var arabic = CharacterSet(charactersIn: Unicode.Scalar(UInt16(0x0600))!...Unicode.Scalar(UInt16(0x06ff))!)
let arabicSupplement = CharacterSet(charactersIn: Unicode.Scalar(UInt16(0x750))!...Unicode.Scalar(UInt16(0x077f))!)
let arabicExtendedA = CharacterSet(charactersIn: Unicode.Scalar(UInt16(0x08a0))!...Unicode.Scalar(UInt16(0x08ff))!)
let arabicPresentationFormsA = CharacterSet(charactersIn: Unicode.Scalar(UInt16(0xfb50))!...Unicode.Scalar(UInt16(0xfdff))!)
let arabicPresentationFormsB = CharacterSet(charactersIn: Unicode.Scalar(UInt16(0xfe70))!...Unicode.Scalar(UInt16(0xfeff))!)
let rumiNumeralSymbols = CharacterSet(charactersIn: Unicode.Scalar(UInt32(0x10e60))!...Unicode.Scalar(UInt32(0x10e7f))!)
let indicSiyaqNumbers = CharacterSet(charactersIn: Unicode.Scalar(UInt32(0x1ec70))!...Unicode.Scalar(UInt32(0x1ecbf))!)
let ottomanSiyaqNumbers = CharacterSet(charactersIn: Unicode.Scalar(UInt32(0x1ed00))!...Unicode.Scalar(UInt32(0x1ed4f))!)
@sstadelman
sstadelman / Repro.swift
Last active May 11, 2019
String length bug
View Repro.swift
//
// Repro.swift
//
// Created by Stadelman, Stan on 5/10/19.
//
import Foundation
/// Sample bidirectional string, which happens to include neutral characters "(" and ")"
/// String source: [Section #1 #1](https://forum.wordreference.com/threads/important-please-read-before-you-post-الرجاء-القراءة-قبل-المشاركة.53282/)
@sstadelman
sstadelman / Activity.swift
Created Aug 20, 2018 — forked from zwaldowski/Activity.swift
os_activity_t for Swift 3
View Activity.swift
//
// Activity.swift
//
// Created by Zachary Waldowski on 8/21/16.
// Copyright © 2016 Zachary Waldowski. Licensed under MIT.
//
import os.activity
private final class LegacyActivityContext {
You can’t perform that action at this time.