Skip to content

Instantly share code, notes, and snippets.

View tieleman's full-sized avatar

Sjoerd Tieleman tieleman

View GitHub Profile
@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 / 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 / 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 / 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
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 / 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 / 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
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 / multiply.swift
Created March 11, 2020 21:46
Multiplication example using vDSP
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()
}
@tieleman
tieleman / vDSPBenchmark.swift
Last active March 12, 2020 08:34
Xcode playground code for benchmarking a Swifty implementation vs. vDSP.
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 {