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
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
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 = "" | |
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
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
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
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
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
func multiply(_ array: [Double]) -> [Double] { | |
// Allocate memory for the output array | |
let output = UnsafeMutablePointer<Double>.allocate(capacity: array.count) | |
// Make sure we free up the memory once we're done | |
defer { | |
output.deinitialize(count: array.count) | |
output.deallocate() | |
} | |
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 Accelerate | |
import XCTest | |
let array = Array(stride(from: 0.0, to: 50000.0, by: 1)) | |
let array2 = Array(stride(from: 0.0, to: 50000.0, by: 1)) | |
let array3 = Array(stride(from: 0.0, to: 50000.0, by: 1)) | |
class MathTests: XCTestCase { | |
func testMeanSwifty() { | |
measure { |