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 SwiftUI | |
import MapKit | |
// Main view | |
struct ContentView: View { | |
// Provides an annotation immedidately (synchronously) | |
var synchronousAnnotationMaker = SynchronousAnnotationMaker() | |
var body: some View { |
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
# Workflow to build and deploy site to Github Pages using Hugo | |
# Name of Workflow | |
name: github pages | |
# Controls when the action will run. Triggers the workflow on push or pull request | |
# events but only for the master branch | |
on: | |
push: | |
branches: [ master ] |
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
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { | |
// ... | |
guard fetchedElements.last! != knownOldestElement else { return } | |
// Fetch next page | |
// ... |
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
ref.queryOrderedByKey().queryEnding(atValue: "last_fetched_element_key").queryLimited(toLast: limit).observeSingleEvent(of: .value, with: { snapshot in | |
// Do stuff with this page of elements | |
//... | |
}) |
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
fileprivate let ref = FIRDatabase.database().reference().child("List_of_stuff") | |
_ = ref.queryLimited(toLast: 30).observe(.value, with: { snapshot in | |
// Do stuff here with the returned elements | |
//... | |
}) | |
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
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
switch segue.destination { | |
case let viewController1 as ViewController1: | |
self.viewController1 = viewController1 | |
case let viewController2 as ViewController2: | |
self.viewController2 = viewController2 | |
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
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
if segue.identifier == "Segue1" { | |
if let viewController1 = segue.destination as? ViewController1 { | |
self.viewController1 = viewController1 | |
} | |
} else if segue.identifier == "Segue12" { | |
if let viewController2 = segue.destination as? ViewController2 { | |
self.viewController2 = viewController2 | |
} |
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
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { | |
var centerCell: UICollectionViewCell? = nil | |
// Get cell being displayed in the center of the screen | |
// Do this by getting the cell that is fully visible | |
for cell in scalingCarousel.visibleCells { | |
let cellRect = scalingCarousel.convert(cell.frame, to: nil) | |
// Get the cell that is fully visible, this will have an origin x value between 30 and 70 |
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 UITextView { | |
/** | |
Calculates if new textview height (based on content) is larger than a base height | |
- parameter baseHeight: The base or minimum height | |
- returns: The new height | |
*/ | |
func newHeight(withBaseHeight baseHeight: CGFloat) -> CGFloat { |