Skip to content

Instantly share code, notes, and snippets.

View nferruzzi's full-sized avatar

Nicola Ferruzzi nferruzzi

  • Self-Employed
  • Firenze
View GitHub Profile
@nferruzzi
nferruzzi / gist:06abe735c70af9f55e359cae6729bfe3
Last active February 29, 2024 08:19
How to use MapBox MGLOpenGLStyleLayer to draw a triangle at the required geo coordinates
import Foundation
import Mapbox
import GLKit
extension Double {
func clamp(min: Double, max: Double) -> Double {
return Double.minimum(Double.maximum(self, min), max)
}
}
@nferruzzi
nferruzzi / ReSwift+select.swift
Last active February 28, 2018 05:56
My own ReSwift multi observer extension with support for equatable types and optionals of equatable types
// Promise like subscriber, works with Equatable types and Optionals of Equatable types
// ie:
// let observer = document.mainStore
// .select { (state) -> UIState in state.ui }
// .then { _ in called += 1 }
// or
// let observer = document.mainStore
// .select { (state) -> String? in state.ui.selection }
// .then { _ in called += 1 }
//