This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func flatMap<U, V, T>(_ i: U?, _ j: V?, block: (U, V)->T) -> T? { | |
var result: T? | |
if let i = i, let j = j { result = block(i,j) } | |
return result | |
} | |
func flatMap<U, V, W, T>(_ i: U?, _ j: V?, _ k: W?, block: (U, V, W)->T) -> T? { | |
var result: T? | |
if let i = i, let j = j, let k = k { result = block(i,j,k) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enter two file names as arguments. | |
# Will print out the ones that appear in both files. | |
# This is a set intersection. | |
emails-common-to-both () { | |
comm -12 -i <(sort -u -f "$1") <(sort -u -f "$2"); | |
}; | |
# Enter two filenames. | |
# Will print emails from first that don't appear in second. | |
# This is like a set subtraction. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# To use this, just put the DSYMS in the same directory as the sample dump file, | |
# and run the script from that directory, passing the sample dump file name as only argument | |
# | |
import re, sys, os, subprocess | |
sampleFile = sys.argv[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct NuclearPowerStationOperator { | |
class Storage { | |
var turnOffCores: Bool = false | |
func copy() -> Storage { | |
let new = Storage() | |
new.turnOffCores = turnOffCores | |
return new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct Small { | |
var i: Int | |
var j: Int | |
} | |
var s = Small(i: 1, j: 2) | |
DispatchQueue.global(qos: .background).async { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here is some SwiftUI code I have. | |
------ | |
NavigationView { | |
List(translations) { translation in | |
Button(action: { | |
self.dataSource.selectedTranslationId = translation.id | |
}) { | |
TranslationCell(translation: translation) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys, os.path | |
import os | |
import json | |
from xml.dom.minidom import parse | |
rootdir = os.getcwd() | |
lgPaths = ["iOS/AuthKitUI.lg", "iOS/CalendarUIKit.lg", "iOS/iCloudDriveSettings.lg", "iOS/MobileNotes.lg", "macOS/CalendarUI.lg", "macOS/Finder_FE.lg", "macOS/Finder_FinderKit.lg", "macOS/iCloudPrefPane.lg", "macOS/Notes.lg", "macOS/Reminders.lg", "macOS/TextEdit.lg"] | |
languageDirs = ["Dutch", "French"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SwiftUI | |
import Combine | |
let dateFormatter: DateFormatter = { | |
let dateFormatter = DateFormatter() | |
dateFormatter.locale = Locale(identifier: "en_US_POSIX") | |
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ" | |
return dateFormatter | |
}() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Lightweight but powerful state machine. | |
// | |
// Usage: | |
// enum TrafficLight: State { | |
// case red, orange, green | |
// } | |
// | |
// var trafficLights = StateMachine<TrafficLight>(initialState: .red) | |
// trafficLights.addRoute(from: .red, to: .green) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Label: Hashable { | |
var label: String | |
} | |
protocol LabelUniquing { | |
var label: Label { get } | |
} | |
extension LabelUniquing { |