Skip to content

Instantly share code, notes, and snippets.

@AvdLee
AvdLee / DarwinNotificationCenter.swift
Last active January 23, 2024 07:55
A notification center for Darwin Notifications. MIT License applies.
//
// DarwinNotificationCenter.swift
//
// Copyright © 2017 WeTransfer. All rights reserved.
//
import Foundation
/// A Darwin notification payload. It does not contain any userInfo, a Darwin notification is purely event handling.
public struct DarwinNotification {
@mayrestinpeace
mayrestinpeace / locationIndexOnEdgeOrPath.swift
Created August 15, 2019 01:44
Check if a point lies on a polyline in swift. Return -1 if it does not or i if it lies between polyline[i] and polyline[i+1]
import UIKit
struct LatLng {
var latitude: Double
var longitude: Double
}
let EARTH_RADIUS = 6371009.0
func hav(_ x: Double) -> Double {