Skip to content

Instantly share code, notes, and snippets.

View nickkohrn's full-sized avatar

Nick Kohrn nickkohrn

  • Lima, OH
  • 04:11 (UTC -04:00)
View GitHub Profile
@TaylorBurnham
TaylorBurnham / NINA_Tokens.md
Last active January 21, 2025 14:06
N.I.N.A Tokens for Astrophotography

N.I.N.A Astrophotography Tokens

I wanted a place other than the UI to reference tokens for configuring complex sequences. Please comment with any discrepancies or updates.

N.I.N.A Image Naming Tokens

Pulled from the source at nina on branch release/2.0 and commit f19a006.

Token Description
@darrarski
darrarski / FormattedTextField.swift
Last active September 26, 2024 06:33
SwiftUI FormattedTextField - TextField with custom display/edit formatters
import SwiftUI
public struct FormattedTextField<Formatter: TextFieldFormatter>: View {
public init(_ title: String,
value: Binding<Formatter.Value>,
formatter: Formatter) {
self.title = title
self.value = value
self.formatter = formatter
}
@JadenGeller
JadenGeller / Random.swift
Last active May 25, 2017 20:23
Random Numbers in Swift
struct Random {
static func within<B: protocol<Comparable, ForwardIndexType>>(range: ClosedInterval<B>) -> B {
let inclusiveDistance = range.start.distanceTo(range.end).successor()
let randomAdvance = B.Distance(arc4random_uniform(UInt32(inclusiveDistance.toIntMax())).toIntMax())
return range.start.advancedBy(randomAdvance)
}
static func within(range: ClosedInterval<Float>) -> Float {
return (range.end - range.start) * Float(Float(arc4random()) / Float(UInt32.max)) + range.start
}
@cypres
cypres / Easter.swift
Last active March 27, 2021 17:08
Easter calculation in Swift
// Easter calculation in swift after Anonymous Gregorian algorithm
// Also known as Meeus/Jones/Butcher algorithm
import Foundation
func easter(Y : Int) -> NSDate {
let a = Y % 19
let b = Int(floor(Double(Y) / 100))
let c = Y % 100
let d = Int(floor(Double(b) / 4))