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
<?xml version="1.0" ?> | |
<!-- | |
This sample schedules a task to start about 10 seconds after the task is deployed. | |
--> | |
<Task> | |
<Triggers> | |
<TimeTrigger> | |
<Enabled>true</Enabled> | |
<Delay>PT10S</Delay> | |
</TimeTrigger> |
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
let fm = try FileManager.default.contentsOfDirectory(atPath: "./") | |
print(fm.count) |
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
// Set up the ls process | |
let lsProc = Process() | |
let lsStdout = Pipe() | |
lsProc.launchPath = "/bin/ls" | |
lsProc.standardOutput = lsStdout | |
// set up the wc process | |
let wcProc = Process() | |
let wcStdout = Pipe() | |
wcProc.launchPath = "/usr/bin/wc" |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<array> | |
<dict> | |
<key>_SPCommandLineArguments</key> | |
<array> | |
<string>/usr/sbin/system_profiler</string> | |
<string>-nospawn</string> | |
<string>-xml</string> |
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
public func getItemsFromSystemProfiler(dataTypeString: String) -> [[String:AnyObject]]? { | |
let task = Process() | |
let pipe = Pipe() | |
// Set up our task process | |
task.launchPath = "/usr/sbin/system_profiler" | |
task.arguments = ["-xml", dataTypeString] | |
task.standardOutput = pipe | |
// Go! |
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
let hwinfo = launchAndGetText(path:"/usr/sbin/system_profiler", | |
args: ["SPHardwareDataType"]) | |
let lines = hwinfo.components(separatedBy: "\n") | |
var uuid: String = "" | |
for line in lines { | |
let parts = line.components(separatedBy: ":") | |
if parts.count > 1 && parts[0].contains("Hardware UUID") { | |
uuid = parts[1].trimmingCharacters(in: CharacterSet.whitespaces) |
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
public func launchAndGetText(path: String, args: [String]) -> String { | |
let ps = Process() | |
ps.launchPath = path | |
ps.arguments = args | |
let psStdOut = Pipe() | |
ps.standardOutput = psStdOut | |
ps.launch() | |
ps.waitUntilExit() |
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
let spProc = Process() | |
spProc.launchPath = "/usr/sbin/system_profiler" | |
spProc.arguments = ["SPHardwareDataType"] | |
spProc.launch() | |
spProc.waitUntilExit() |
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
do { | |
var coyote = Predator() | |
var roadrunner = Prey() | |
coyote.attach(device:"rocket", location: "back") | |
coyote.attach(device:"roller skates", location: "feet") | |
coyote.attach(device:"helmet", location: "head") | |
try coyote.navigate(feature: "Sharp Turn") |