Skip to content

Instantly share code, notes, and snippets.

Avatar

Jayesh Kawli jayesh15111988

View GitHub Profile
View virusOriginator.swift
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 {
@jayesh15111988
jayesh15111988 / TransactionOperation.swift
Last active Oct 25, 2020
This is the Swift implementation to perform basic database operations
View TransactionOperation.swift
//
// TransactionOperation.swift
// NotificationCenterImplementation
//
// Created by Jayesh Kawli on 10/18/20.
// Copyright © 2020 Jayesh Kawli. All rights reserved.
//
import Foundation
View MyNotificationCenter.swift
//
// MyNotificationCenter.swift
// MyNotificationCenterImplementation
//
// Created by Jayesh Kawli on 10/12/19.
// Copyright © 2019 Jayesh Kawli. All rights reserved.
//
import Foundation
View MovieCell.swift
//
// MovieCell.swift
//
import UIKit
final class MovieCell: UITableViewCell {
let posterImageView = UIImageView(frame: .zero)
@jayesh15111988
jayesh15111988 / ImageDownloader.swift
Created Apr 26, 2020
A gist for image downloader and caching library written in Swift for iOS applications
View ImageDownloader.swift
import UIKit
// Image downloader utility class. We are going to use the singleton instance to be able to download required images and store them into in-memory cache.
final class ImageDownloader {
static let shared = ImageDownloader()
private var cachedImages: [String: UIImage]
private var imagesDownloadTasks: [String: URLSessionDataTask]
View ScrollViewSupportViewController.swift
//
// ScrollViewSupportViewController.swift
// Sample
//
// Created by Jayesh Kawli on 2/23/19.
// Copyright © 2019 Jayesh Kawli. All rights reserved.
//
import UIKit
View ScrollViewAutolayoutCreator.swift
//
// AutolayoutScrollView.swift
// Sample
//
// Created by Jayesh Kawli on 2/23/19.
// Copyright © 2019 Jayesh Kawli. All rights reserved.
//
import UIKit
@jayesh15111988
jayesh15111988 / SwiftyTableView.swift
Created Feb 20, 2017
A tableview with Swifty style
View SwiftyTableView.swift
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 {
View indirectEnum.swift
// 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)
@jayesh15111988
jayesh15111988 / swift-error-handling.swift
Created Jan 23, 2017
A Sample code to demonstrate Swift error handling
View swift-error-handling.swift
import Foundation
enum PasswordError: Error {
case TooShort
case NoNumber
case CustomMessage(message: String)
}
class PasswordChecker {