layout: post title: "ReactiveCocoa Unit Testing Tips" date: 2013-09-22 20:45 comments: true categories:
- Testing
- iOS
- Patterns
- Xcode
#define MSDesignatedInitializer(__SEL__) __attribute__((unavailable("Invoke the designated initializer `" # __SEL__ "` instead."))) | |
// Sample usage: | |
- (instancetype)initWithObject:(id)object; | |
- (instancetype)init MSDesignatedInitializer(initWithObject:); // <- This even gets auto-complete. | |
// Now calling init on this class would throw a warning. |
CLASS_NAME = MyObject | |
OBJS = main.o $(CLASS_NAME).o $(CLASS_NAME)Tests.o | |
PROGRAM = a.out | |
CFLAGS = -Wall -F$(FWPATH) | |
LIBS = -F$(FWPATH) -framework XCTest -framework Foundation | |
FWPATH = /Applications/Xcode.app/Contents/Developer/Library/Frameworks | |
XCTEST = /Applications/Xcode.app/Contents/Developer/usr/bin/xctest |
layout: post title: "ReactiveCocoa Unit Testing Tips" date: 2013-09-22 20:45 comments: true categories:
#!/bin/bash | |
############################################################################ | |
# Automated WWDC 2014 videos downloader script | |
# Cristian Grau @SaroFR | |
# Based on Krzysztof Zablocki's (@merowing_) Download HD WWDC 2014 command | |
############################################################################ | |
function download { | |
curl --silent --remote-name $1 |
#!/usr/bin/env ruby | |
device_types_output = `xcrun simctl list devicetypes` | |
device_types = device_types_output.scan /(.*) \((.*)\)/ | |
runtimes_output = `xcrun simctl list runtimes` | |
runtimes = runtimes_output.scan /(.*) \(.*\) \((com.apple[^)]+)\)$/ | |
devices_output = `xcrun simctl list devices` | |
devices = devices_output.scan /\s\s\s\s(.*) \(([^)]+)\) (.*)/ |
I was playing with GitHub Archive recently. Out of curiosity I ran this query:
SELECT COUNT(repository_owner) as totalStars, repository_owner
FROM [githubarchive:github.timeline]
WHERE type = 'WatchEvent'
GROUP BY repository_owner
ORDER BY totalStars DESC
LIMIT 1000
func exponentialMovingAverage(currentAverage: Double, newValue: Double, smoothing: Double) -> Double { | |
return smoothing * newValue + (1 - smoothing) * currentAverage | |
} | |
// Usage: | |
// var a = 3 | |
// a = exponentialMovingAverage(a, 8, 0.5) | |
// Swift 2 |
#!/usr/bin/env ruby | |
require 'JSON' | |
device_types = JSON.parse `xcrun simctl list -j devicetypes` | |
runtimes = JSON.parse `xcrun simctl list -j runtimes` | |
devices = JSON.parse `xcrun simctl list -j devices` | |
devices['devices'].each do |runtime, runtime_devices| | |
runtime_devices.each do |device| |