I hereby claim:
- I am tiwoc on github.
- I am dseither (https://keybase.io/dseither) on keybase.
- I have a public key ASCYr5gKU4ekiCvicb4kcVSKr_ZxiSUC3Qo9Vf8w6BPpuQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
/** | |
Dijkstra's algorithm in Swift 3 | |
The idea is to create a more protocol oriented implementation. | |
Note: It could use some optimizations, if you wish to use in production. | |
*/ | |
import Foundation |
// | |
// ConnectivityUtility.swift | |
// | |
// Created by Adrian Bolinger on 7/10/18. | |
// Copyright © 2018 Adrian Bolinger. All rights reserved. | |
// | |
import UIKit | |
import Reachability |
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller | |
{ | |
self.shouldReloadCollectionView = NO; | |
self.blockOperation = [[NSBlockOperation alloc] init]; | |
} | |
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo | |
atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type | |
{ | |
__weak UICollectionView *collectionView = self.collectionView; |
import UIKit | |
extension UIImage { | |
// colorize image with given tint color | |
// this is similar to Photoshop's "Color" layer blend mode | |
// this is perfect for non-greyscale source images, and images that have both highlights and shadows that should be preserved | |
// white will stay white and black will stay black as the lightness of the image is preserved | |
func tint(tintColor: UIColor) -> UIImage { | |
import Foundation | |
import CoreLocation | |
/* | |
θ = atan2( sin Δλ ⋅ cos φ2 , cos φ1 ⋅ sin φ2 − sin φ1 ⋅ cos φ2 ⋅ cos Δλ ) | |
where φ1,λ1 is the start point, φ2,λ2 the end point (Δλ is the difference in longitude) | |
*/ | |
func calculateBearing(from: CLLocationCoordinate2D, to: CLLocationCoordinate2D) -> Double { | |
let x1 = from.longitude * (Double.pi / 180.0) |
// | |
// CoreDataController.swift | |
// | |
// Created by Keith Harrison http://useyourloaf.com | |
// Copyright (c) 2017 Keith Harrison. All rights reserved. | |
// | |
// Redistribution and use in source and binary forms, with or without | |
// modification, are permitted provided that the following conditions are met: | |
// | |
// 1. Redistributions of source code must retain the above copyright |
import UIKit | |
extension UIImage { | |
// colorize image with given tint color | |
// this is similar to Photoshop's "Color" layer blend mode | |
// this is perfect for non-greyscale source images, and images that have both highlights and shadows that should be preserved | |
// white will stay white and black will stay black as the lightness of the image is preserved | |
func tint(tintColor: UIColor) -> UIImage { | |
// prepare bbox | |
struct BoundingBox { | |
// latitudes range from -90 .. +90 | |
// longitudes range from -180 .. +180 | |
var latmin = 90.0 | |
var latmax = -90.0 | |
var lngmin = 180.0 | |
var lngmax = -180.0 | |
} | |
var bbox = BoundingBox() |
import MapKit | |
extension MKCoordinateRegion { | |
init?(coordinates: [CLLocationCoordinate2D]) { | |
// first create a region centered around the prime meridian | |
let primeRegion = MKCoordinateRegion.region(for: coordinates, transform: { $0 }, inverseTransform: { $0 }) | |
// next create a region centered around the 180th meridian |