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
func sortConvex(input: [CLLocationCoordinate2D]) -> [CLLocationCoordinate2D] { | |
// X = longitude | |
// Y = latitudeß | |
// 2D cross product of OA and OB vectors, i.e. z-component of their 3D cross product. | |
// Returns a positive value, if OAB makes a counter-clockwise turn, | |
// negative for clockwise turn, and zero if the points are collinear. | |
func cross(P: CLLocationCoordinate2D, A: CLLocationCoordinate2D, B: CLLocationCoordinate2D) -> Double { | |
let part1 = (A.longitude - P.longitude) * (B.latitude - P.latitude) |
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
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
cell.rankLabel.isHidden = true | |
if let rank = list.rank { | |
cell.rankLabel.setTitle(title: rank, titleFont: UIFont.customBold!, colour: .white) | |
cell.rankLabel.isHidden = false | |
} | |
} |
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 | |
struct product { | |
var price:Int? | |
var name:String | |
} | |
let array = [ | |
product(price: 100, name: "First"), | |
product(price: nil, name: "Second"), |
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
var timer:Timer! | |
var degree = 0 | |
@objc func rotate() { | |
// assumes google map called 'map' | |
self.map.animate(toBearing: CLLocationDirection(degree)) | |
if degree == 360 { | |
timer.invalidate() // comment out this line for continual rotation | |
degree = 0 | |
} | |
degree += 18 |
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
// BackgroundLocation.swift | |
import Foundation | |
class LocationManger : NSObject, CLLocationManagerDelegate { | |
static let sharedManager = LocationManger() | |
var locationManager:CLLocationManager! | |
var lastTimestamp:NSDate! |
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
class CustomTabbar:UITabBarController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let data = [ | |
1:"data", | |
2:"data", | |
3:"data", | |
4:"data" |
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
class ToggleHiddenLabel:UILabel { | |
var heightConstraint:NSLayoutConstraint! | |
var visible:Bool = false { | |
didSet { | |
if visible { | |
self.removeConstraint(self.heightConstraint) | |
self.hidden = false | |
} else { | |
self.addConstraint(self.heightConstraint) |
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
require 'fileutils' | |
from = ARGV[0] | |
to = ARGV[1] | |
# Max source directory size set to 100gb | |
maxSourceSize = 107374182400 | |
def directory_size(path) | |
path << '/' unless path.end_with?('/') |
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
extension UIView { | |
func roundCorners(corners:UIRectCorner, radius:CGFloat) { | |
let bounds = self.bounds; | |
let maskPath:UIBezierPath = UIBezierPath(roundedRect: bounds, byRoundingCorners: corners, cornerRadii: CGSizeMake(radius, radius)) | |
let maskLayer:CAShapeLayer = CAShapeLayer() | |
maskLayer.frame = bounds | |
maskLayer.path = maskPath.CGPath |
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
TAGS="TODO:|FIXME:" | |
echo "searching ${SRCROOT} for ${TAGS}" | |
find "${SRCROOT}" \( -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/" |
NewerOlder