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
public static class Extensions | |
{ | |
public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component | |
{ | |
if(gameObject.TryGetComponent<T>(out T t)) | |
{ | |
return t; | |
} | |
else | |
{ |
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
# | |
# Git attributes for Unity projects | |
# | |
# Compiled by the GameCI community under the MIT license - https://game.ci | |
# | |
# Latest version at https://gist.github.com/webbertakken/ff250a0d5e59a8aae961c2e509c07fbc | |
# | |
# Ensure that text files that any contributor introduces to the repository have their line endings normalized | |
* text=auto |
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
// Requirements: a NSLocationWhenInUseUsageDescription entry in Info.plist | |
// Usage: @State var locator = CLLocationManager.publishLocation() | |
// and | |
// .onReceive(locator) { location in | |
// Improvements needed: Move requestWhenInUseAuthorization into its own publisher and perhaps have a combineLatest pipeline for both authorized and valid location. | |
// A configuration param to init(), e.g. so each manager can have the same distanceFilter. | |
import Foundation | |
import Combine | |
import CoreLocation |
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
protocol UnknownCase: RawRepresentable, CaseIterable where RawValue: Equatable & Encodable { | |
static var unknownCase: Self { get } | |
} | |
extension UnknownCase { | |
init(rawValue: RawValue) { | |
let value = Self.allCases.first { $0.rawValue == rawValue } | |
self = value ?? Self.unknownCase | |
} |
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
// | |
// BottomSheetView.swift | |
// | |
// Created by Majid Jabrayilov | |
// Copyright © 2019 Majid Jabrayilov. All rights reserved. | |
// | |
import SwiftUI | |
fileprivate enum Constants { | |
static let radius: CGFloat = 16 |
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
* text=auto | |
# Unity files | |
*.meta -text -merge=unityamlmerge | |
*.unity -text -merge=unityamlmerge | |
*.asset -text -merge=unityamlmerge | |
*.prefab -text -merge=unityamlmerge | |
# Image formats | |
*.psd filter=lfs diff=lfs merge=lfs -text |
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
{ | |
"categories": [ | |
{ | |
"name": "Movies", | |
"videos": [ | |
{ | |
"description": "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org", | |
"sources": [ | |
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" | |
], |
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 Foundation | |
import CoreLocation | |
struct randomLocations { | |
// create random locations (lat and long coordinates) around user's location | |
func getMockLocationsFor(location: CLLocation, itemCount: Int) -> [CLLocation] { | |
func getBase(number: Double) -> Double { | |
return round(number * 1000)/1000 |
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 Int { | |
func formatUsingAbbrevation () -> String { | |
let numFormatter = NSNumberFormatter() | |
typealias Abbrevation = (threshold:Double, divisor:Double, suffix:String) | |
let abbreviations:[Abbrevation] = [(0, 1, ""), | |
(1000.0, 1000.0, "K"), | |
(100_000.0, 1_000_000.0, "M"), | |
(100_000_000.0, 1_000_000_000.0, "B")] |
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
let longPress = UILongPressGestureRecognizer(target: self, action: #selector(upgradeAlertViewOtherUpgradesLongPressHandler)) | |
longPress.minimumPressDuration = 0 | |
var longPressGRStartPoint: CGPoint? | |
var didCancelLongPressGR = false | |
func viewTouched(sender: UILongPressGestureRecognizer) { | |
let currentPoint = sender.location(in: self.view) | |
switch sender.state { | |
case .began: |
NewerOlder