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
URLSession.shared.rx | |
.response(imageURL) | |
// subscribe on main thread | |
.subscribeOn(MainScheduler.sharedInstance) | |
.subscribe(onNext: { [weak self] data in | |
// Update Image | |
self?.imageView.image = UIImage(data: data) | |
}, onError: { | |
// Log error | |
}, onCompleted: { |
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
// create task to download image from url | |
let task = session.dataTask(with: imageURL) {(imageData, response, error) in | |
// check for image data | |
if let data = imageData { | |
// update UI on main thread | |
DispatchQueue.main.async { | |
self.imageView.image = UIImage(data: data) | |
// animate image alpha | |
UIView.animateWithDuration(0.3) { | |
self.imageView.alpha = 1 |
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 assert = require('assert'); | |
exports.handler = function(event, context) { | |
// Log the context, it contains details about the function's execution | |
console.log("Context: %j", context); | |
// Log the event, it contains data and parameters passed to the function | |
console.log("Event: %j",event); | |
try { | |
// Simple example to show that the assert library was successfully included |
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
{ | |
"name": "my-api", | |
"version": "1.0.0", | |
"dependencies": { | |
"assert": "1.3.0" | |
}, | |
"devDependencies": { | |
"browserify": "13.0.0" | |
} | |
} |
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
{ | |
"name": "my-api", | |
"description": "API Lambda Functions", | |
"role": "arn:aws:iam::123456789023:role/lambda-api", | |
"runtime": "nodejs", | |
"handler": "main.handler", | |
"hooks": { | |
"build": "npm install && ../../node_modules/.bin/browserify --node -s default --exclude aws-sdk -o main.js index.js", | |
"clean": "rm -f main.js" | |
} |
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 assertExists(element: XCUIElement, timeout: NSTimeInterval = 10) { | |
expectationForPredicate(NSPredicate(format: "exists == 1"), | |
evaluatedWithObject: element, handler: nil) | |
waitForExpectationsWithTimeout(timeout, handler: nil) | |
} |
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 launchApp() { | |
app.launch() | |
// We have stubbed out the login flow to always succeed, | |
// so the password doesn't matter | |
app.secureTextFields["password_text_field"].typeText("nonsense password\n") | |
app.tabBars.buttons["get care tab button"].tap() | |
} | |
func testCurrentLocationPreSelected() { |
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 setupSearchResults() { | |
let testBlock: OHHTTPStubsTestBlock | |
testBlock = { $0.URL?.path == "/api/v1/getcare/*" } | |
let fixture = OHPathForFile("GetCareResponse.json", self.dynamicType)! | |
successResponseBlock = { _ in | |
return OHHTTPStubsResponse( | |
fileAtPath: fixture, | |
statusCode: 200, | |
headers: ["Content-Type":"application/json"] |
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
// This method is called from | |
// `application(didFinishLaunchingWithOptions:)` | |
private func handleLaunchArguments() { | |
var arguments = NSProcessInfo.processInfo().arguments | |
// The first argument is the path of the executable | |
arguments.removeFirst() | |
for argument in arguments { | |
switch argument { | |
case LaunchArguments.NoAnimations: |
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 app: XCUIApplication! | |
override func setUp() { | |
super.setUp() | |
continueAfterFailure = false | |
app = XCUIApplication() | |
app.launchArguments = [ | |
LaunchArguments.ResetDefaults, |