Skip to content

Instantly share code, notes, and snippets.

View tieleman's full-sized avatar

Sjoerd Tieleman tieleman

View GitHub Profile
@tieleman
tieleman / SimpleGreeterUITests.swift
Created February 26, 2020 12:01
SimpleGreeterUITests v2
import XCTest
class SimpleGreeterUITests: XCTestCase {
override func setUp() {
continueAfterFailure = false
}
func testInitialViewState() {
let app = XCUIApplication()
app.launch()
@tieleman
tieleman / ContentView.swift
Created February 26, 2020 11:59
ContentView.swift v2
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 {
@tieleman
tieleman / SimpleGreeterUITests.swift
Last active February 26, 2020 11:40
SimpleGreeterUITests.swift#testInitialViewState
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")
@tieleman
tieleman / SimpleGreeterUITests.swift
Created February 26, 2020 10:48
SimpleGreeterUITests.swift#testGreeter
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")
@tieleman
tieleman / ContentView.swift
Last active February 26, 2020 11:44
ContentView.swift v1
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()
@tieleman
tieleman / SimpleGreeterUITests.swift
Last active February 25, 2020 19:59
SimpleGreeterUITests v1
import XCTest
class SimpleGreeterUITests: XCTestCase {
override func setUp() {
continueAfterFailure = false
}
func testInitialViewState() {
let app = XCUIApplication()
app.launch()
@tieleman
tieleman / wmstats.rb
Last active August 29, 2015 14:08
wmstats for Ruby
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
@tieleman
tieleman / reader.js
Last active August 29, 2015 13:57
PoC NodeJS script which reads an input MPEG-TS and pipes it to stdout in a loop to be transcoded/segmented by ffmpeg.
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() {
@tieleman
tieleman / spawner.js
Created March 11, 2014 10:33
Spawn example JS
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
})
@tieleman
tieleman / spawner.rb
Last active August 29, 2015 13:57
Spawn example
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."