This file contains hidden or 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 XCTest | |
| class SimpleGreeterUITests: XCTestCase { | |
| override func setUp() { | |
| continueAfterFailure = false | |
| } | |
| func testInitialViewState() { | |
| let app = XCUIApplication() | |
| app.launch() |
This file contains hidden or 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 SwiftUI | |
| struct ContentView: View { | |
| @State private var name: String = "" | |
| private var greeterText: String { | |
| name.isEmpty ? "" : "Nice to meet you, \(name)." | |
| } | |
| var body: some View { |
This file contains hidden or 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 testInitialViewState() { | |
| let app = XCUIApplication() | |
| app.launch() | |
| let textField = app.textFields.element | |
| let enterNameLabel = app.staticTexts["enterNameLabel"] | |
| let greeterLabel = app.staticTexts["greetingTextLabel"] | |
| XCTAssert(enterNameLabel.exists) | |
| XCTAssertEqual(enterNameLabel.label, "Please enter your name below") |
This file contains hidden or 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 testGreeter() { | |
| let app = XCUIApplication() | |
| app.launch() | |
| let textLabel = app.staticTexts["greetingTextLabel"] | |
| let textField = app.textFields.element | |
| textField.tap() | |
| textField.typeText("J") | |
| textField.typeText("o") |
This file contains hidden or 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 SwiftUI | |
| struct ContentView: View { | |
| @State private var name: String = "" | |
| var body: some View { | |
| VStack { | |
| Text("Please enter your name below") | |
| TextField("Your name", text: $name) | |
| }.padding() |
This file contains hidden or 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 XCTest | |
| class SimpleGreeterUITests: XCTestCase { | |
| override func setUp() { | |
| continueAfterFailure = false | |
| } | |
| func testInitialViewState() { | |
| let app = XCUIApplication() | |
| app.launch() |
This file contains hidden or 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
| require 'benchmark' | |
| filename = 'pagecounts-20141029-230000' | |
| min_views = 500 | |
| prefix = 'en ' | |
| count = [] | |
| time = Benchmark.measure do | |
| File.open(filename).each_line do |line| | |
| next unless line.start_with? prefix |
This file contains hidden or 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
| var fs = require('fs'); | |
| function processStream() { | |
| var readStream = fs.createReadStream('../../counter_0_120.ts'); | |
| readStream.on('open', function () { | |
| readStream.pipe(process.stdout, { end: false }); | |
| }); | |
| readStream.on('end', function() { |
This file contains hidden or 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
| var child_process = require('child_process'); | |
| job1 = child_process.spawn('sleep', ['5']) | |
| job2 = child_process.spawn('sleep', ['10']) | |
| job1.on('exit', function(code, signal) { | |
| console.log("Job 1 exited with code " + code + " and signal " + signal); | |
| job2.kill(); // Send SIGTERM to other job | |
| }) |
This file contains hidden or 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
| pid1 = spawn "some_command" | |
| pid2 = spawn "some_other_command" | |
| pid1.on_exit do |status| | |
| puts "Process #1 exited with status code #{status}, aborting." | |
| exit | |
| end | |
| pid2.on_exit do |status| | |
| puts "Process #2 exited with status code #{status}, aborting." |