This file contains 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
<html> | |
<body style='margin:0px;padding:0px;'> | |
<script type='text/javascript' src='http://www.youtube.com/iframe_api'></script> | |
<script type='text/javascript'> | |
var ytplayer; | |
function timeElapsed() { | |
return Math.floor(ytplayer.getCurrentTime()) | |
} |
This file contains 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 Foundation | |
import UIKit | |
protocol DownloadAccountProtocol { | |
func downloadAccount(with name: String, completion: (Person) -> ()) | |
} | |
class ServerDownloader: DownloadAccountProtocol { | |
func downloadAccount(with name: String, completion: (Person) -> ()) { | |
let personDictionary: [String: String] = [:] // Dictionary JSON downloaded from server |
This file contains 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
private var searchTimer: Timer? | |
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { | |
if let searchTimer = searchTimer { | |
searchTimer.invalidate() | |
} | |
searchTimer = Timer.scheduledTimer(timeInterval: 0.4, target: self, selector: #selector(self.reload(timer:)), userInfo: searchText, repeats: false) | |
} | |
func reload(timer: Timer) { |
This file contains 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 Foundation | |
enum PasswordError: Error { | |
case TooShort | |
case NoNumber | |
case CustomMessage(message: String) | |
} | |
class PasswordChecker { |
This file contains 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 | |
public indirect enum BrickDimension { | |
case Ratio(ratio: CGFloat) | |
case Fixed(size: CGFloat) | |
case Fill | |
case Auto(estimate: BrickDimension) | |
case Orientation(landscape: BrickDimension, portrait: BrickDimension) | |
case HorizontalSizeClass(regular: BrickDimension, compact: BrickDimension) | |
case VerticalSizeClass(regular: BrickDimension, compact: BrickDimension) |
This file contains 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 | |
// Reference: https://medium.com/swift-programming/upgrade-your-tableviews-with-loading-state-in-swift-1fdce34ada77#.w4sg0dwhk | |
class SwiftyTableView: UIViewController, UITableViewDelegate, UITableViewDataSource { | |
let tableView: UITableView = UITableView() | |
let activityIndicator: UIActivityIndicatorView = UIActivityIndicatorView() | |
var tableState = TableState<String>.Loading { | |
didSet { |
This file contains 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
// | |
// ScrollViewSupportViewController.swift | |
// Sample | |
// | |
// Created by Jayesh Kawli on 2/23/19. | |
// Copyright © 2019 Jayesh Kawli. All rights reserved. | |
// | |
import UIKit |
This file contains 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
// | |
// AutolayoutScrollView.swift | |
// Sample | |
// | |
// Created by Jayesh Kawli on 2/23/19. | |
// Copyright © 2019 Jayesh Kawli. All rights reserved. | |
// | |
import UIKit |
This file contains 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
// | |
// TransactionOperation.swift | |
// NotificationCenterImplementation | |
// | |
// Created by Jayesh Kawli on 10/18/20. | |
// Copyright © 2020 Jayesh Kawli. All rights reserved. | |
// | |
import Foundation |
This file contains 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
let graphNodes = [(1, 2), (2, 3), (2, 4), (4, 5), (4, 6), (5, 4)] | |
var nodeToIncomingEdgesCountMapping: [Int: Int] = [:] | |
for node in graphNodes { | |
if nodeToIncomingEdgesCountMapping[node.0] == nil { | |
nodeToIncomingEdgesCountMapping[node.0] = 0 | |
} | |
if nodeToIncomingEdgesCountMapping[node.1] == nil { |
OlderNewer