Skip to content

Instantly share code, notes, and snippets.

@deepakpk009
deepakpk009 / media.json
Created November 8, 2017 14:02
sample free video urls
{
"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"
],
@nailuj05
nailuj05 / GetOrAddComponent.cs
Last active April 25, 2024 13:46
A simple extension method for Unity C# this gets or adds a given Component. (SphereCollider coll = gameObject.GetOrAddComponent<SphereCollider>();)
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
{
//
// BottomSheetView.swift
//
// Created by Majid Jabrayilov
// Copyright © 2019 Majid Jabrayilov. All rights reserved.
//
import SwiftUI
fileprivate enum Constants {
static let radius: CGFloat = 16
@webbertakken
webbertakken / .gitattributes
Last active March 19, 2024 17:46
.gitattributes for Unity projects
#
# 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
@malhal
malhal / CLLocationManager+Combine.swift
Last active February 12, 2024 23:19
A Combine location publisher for CLLocationManager.
// 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
@saoudrizwan
saoudrizwan / TouchUpInsideViews.swift
Last active October 29, 2023 14:16
Using a long press gesture recognizer, you can recreate a 'touch up inside' button effect on any view.
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:
@inorganik
inorganik / randomLocations.swift
Created June 22, 2017 14:37
Return a cluster of random locations around a given location
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
@bpesquet
bpesquet / .gitattributes-lfs-unity
Last active December 7, 2022 22:37
.gitattributes file for LFS with Unity
* 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
@gbitaudeau
gbitaudeau / Int+Extenstion.swift
Created March 3, 2017 09:44
iOS solution to convert large numbers to smaller format. See : http://stackoverflow.com/a/35504720/1661338
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")]
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
}