Skip to content

Instantly share code, notes, and snippets.

View sstadelman's full-sized avatar
🚀

Stan Stadelman sstadelman

🚀
View GitHub Profile
import Foundation
func testIsBST() {
let list = [2, -10, -45, 200, 48, 10, 38, 47, 4, 2, 5]
var tree = BinaryTree<Int>(2)
for i in list[1...] {
tree.insert(i)
}
let test = isBST(tree)
# references: https://oleb.net/2020/swift-docker-linux/
# TO LAUNCH DOCKER SWIFT ENV (from package root)
docker pull swiftlang/swift:nightly-5.3-bionic
# docker run --rm --privileged --interactive --tty --volume "$(pwd):/src" --workdir "/src" swift:latest
docker run --rm --privileged --interactive --tty --volume "$(pwd):/src" --workdir "/src" swiftlang/swift:nightly-5.3-bionic
# FROM INSIDE DOCKER
apt-get update && apt-get upgrade
apt-get install libsqlite3-dev
@sstadelman
sstadelman / String+RegEx.swift
Created July 12, 2020 04:25
String + Lookahead capture
extension String {
var lookaheadCapture: String {
#"\s?\#(self)\s+(?<\#(self)>(\S++))"#
}
}
@sstadelman
sstadelman / String+RegEx.swift
Created July 12, 2020 04:25
String + Lookahead capture
extension String {
var lookaheadCapture: String {
#"\s?\#(self)\s+(?<\#(self)>(\S++))"#
}
}
@sstadelman
sstadelman / git-check-status.sh
Last active February 26, 2020 21:40
Check status of nested repositories
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
brew install cmake ninja
brew install sccache
mkdir swift-source
cd swift-source
git clone --branch swift-5.1.5-RELEASE [email protected]: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 November 19, 2019 23:03
Example of Codable enum
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 November 19, 2019 21:32
Matcher to find mustache placeholder keys and replacement ranges
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 {
brew install cmake ninja
mkdir swift-source
cd swift-source
git clone [email protected]: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
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))!)