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 | |
class SegmentedControlSupplementaryView: UICollectionReusableView { | |
let segmentControl = UISegmentedControl(items: ["Item 1", "Items 2", "Items 3"]) | |
static let reuseIdentifier = "segmented-supplementary-reuse-identifier" | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
self.backgroundColor = .white |
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
# ---------------------- | |
# Git Aliases | |
# ---------------------- | |
alias ga='git add .' | |
alias gau='git add --update' | |
alias gb='git branch' | |
alias gbd='git branch --delete ' | |
alias gc='git commit' | |
alias gcm='git commit --message' | |
alias gco='git checkout' |
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
//Algorithm: Sieve of Eratosthenes | |
//Swift 2.0 implementation for retreving all the primes until the given limit | |
func findPrimesUntil(limit limit: Int) -> [Int]? { | |
guard limit > 1 else { | |
return .None | |
} | |
var primes = [Bool](count: limit+1, repeatedValue: true) | |
for i in 0..<2 { |
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
extension Request { | |
public func responseAEXMLDocument(completionHandler: (NSURLRequest, NSHTTPURLResponse?, AEXMLDocument?, NSError?) -> Void) -> Self { | |
return response { (request: NSURLRequest, response: NSHTTPURLResponse?, responseObj: AnyObject?, responseError: NSError?) -> Void in | |
var parse_error: NSError? | |
if let obj = responseObj as? NSData, xml = AEXMLDocument(xmlData: obj, error: &parse_error) { | |
if let aerror = parse_error{ | |
completionHandler(request, response, nil, aerror) | |
} else { | |
completionHandler(request, response, xml, responseError) | |
} |
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
// | |
// UIStoryBoard+Extensions.swift | |
// | |
// Created by Prasad Pamidi on 7/29/15. | |
// Copyright (c) 2015. All rights reserved. | |
// | |
import UIKit | |
enum SegueIdentifier:String { |
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
//Famous pattern matching algorithm implementation in Swift | |
func FindMatch(text: [Character], pattern: [Character]) -> [Int] { | |
let t = count(text) | |
let p = count(pattern) | |
var i = 0 | |
var j = 0 | |
var matchedIdxs: [Int] = [] |
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 Foundation | |
//popular sorting algorithms in swift | |
//Insertion Sort | |
//Complexity - Best O(n) - Average O(n2) | |
//We will perform comparing adjacent elements in the array for array length times | |
func InsertionSort<T: Comparable>(var list:[T]) -> [T] { | |
for i in 1..<list.count { |