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
| const https = require('https') | |
| module.exports = { | |
| request : function() { | |
| return new Promise(function(resolve, reject) { | |
| var options = { | |
| host:'www.toggl.com', | |
| path:'/api/v8/time_entries/start', | |
| method: 'POST', | |
| headers: { |
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
| const https = require('https') | |
| module.exports = { | |
| request : function() { | |
| return new Promise(function(resolve, reject) { | |
| var options = { | |
| host: 'api.spotify.com', | |
| path: '/v1/me/player/currently-playing', | |
| method: 'GET', | |
| headers: { |
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 NumberFormatterTests: XCTestCase { | |
| func testRoundingTypeFloor() { | |
| let formatter = NumberFormatter() | |
| formatter.roundingMode = .floor | |
| let number = NSNumber(value: 8.8) | |
| let expectedRoundingValue = "8" |
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 NSNumberTests: XCTestCase { | |
| func testNumberReturnIntValue() { | |
| let rawNumberFloat: Float = 8.74 | |
| let number = NSNumber(value: rawNumberFloat) | |
| let expectedReturnValue: Int = 8 | |
| let actualReturnValue = number.intValue |
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
| /* ========== MVC ========== */ | |
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| if let cell = tableView.dequeueReusableCell(withIdentifier: "PhotoInfoCell", for: indexPath) as? PhotoInfoCell { | |
| let photoInfo = photos[indexPath.row] | |
| cell.configure(title: photoInfo.title, date: photoInfo.date) | |
| cell.startAnimating() | |
| ImageCache.shared.imageFor(url: photoInfo.photoUrl) | |
| .observeOn(MainScheduler.instance) | |
| .subscribe(onNext: { image in | |
| cell.setImage(image: image) |
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
| // Present/push view controller | |
| @IBAction func nextTapped(_ sender: UIButton) { | |
| let src = self | |
| let dst = NextViewController() | |
| src.view.superview?.insertSubview(dst.view, aboveSubview: src.view) | |
| dst.view.transform = CGAffineTransform(translationX: src.view.frame.size.width, y: 0) | |
| UIView.animate(withDuration: 0.25, delay: 0.0, options: UIViewAnimationOptions.curveEaseInOut, animations: { | |
| dst.view.transform = CGAffineTransform(translationX: 0, y: 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
| protocol Service {} | |
| class RealService: Service {} | |
| class DefaultService: Service {} | |
| class NotDependencyInjection { | |
| private let service: Service | |
| init() { | |
| service = RealService() | |
| } |
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 UIKit | |
| let BILLIARD_BALL_SIZE = CGSize(width: 100, height: 100) | |
| let BILLIARD_NUMBER_SIZE = CGSize(width: 50, height: 50) | |
| enum ColorMapping: Int { | |
| case zero = 0 // cue ball | |
| case one = 1 | |
| case two = 2 | |
| case three = 3 |