Skip to content

Instantly share code, notes, and snippets.

@wonderbit
wonderbit / DockInfo.swift
Created November 28, 2016 19:04
Get the Dock position, size and hidden state in a Cocoa app
//
// DockInfo.swift
//
// Created by Wessley Roche on 28/11/2016.
//
import Foundation
enum WBDockPosition: Int {
case bottom = 0
@wonderbit
wonderbit / FloatingPoint+isNearlyEqual.swift
Created November 25, 2022 08:08
Compare nearly equal floating point values
import Foundation
extension FloatingPoint {
func isNearlyEqual(to value: Self, tolerance: Self = 0.00001) -> Bool {
return value < self + tolerance && value > self - tolerance
}
}
@wonderbit
wonderbit / UICellConfiguration+debugPrint.swift
Created December 12, 2022 06:47
Print easy to read description of UICellConfigurationState
extension UICellConfigurationState {
func debugPrint() {
var statuses: [String] = []
if isFocused { statuses.append("focused") }
if isHighlighted { statuses.append("highlighted") }
if isSelected { statuses.append("selected") }
if isSwiped { statuses.append("swiped") }
if isEditing { statuses.append("editing") }
if isDisabled { statuses.append("disabled") }
if isExpanded { statuses.append("expanded") }
@wonderbit
wonderbit / DragAndDropBetweenLazyVGrids.swift
Last active March 20, 2024 12:27
A working implementation of drag and drop between two LazyVGrid elements in SwiftUI
//
// DragAndDropView.swift
// DragAndDropView_Example
//
// Created by Wessley Roche on 11/5/23.
//
import SwiftUI
import UniformTypeIdentifiers
@wonderbit
wonderbit / url_scheme.md
Created December 11, 2023 14:07
Everlog URL Scheme

To create entries:

  • everlog://newEntry?content=Hello%20world (Creates a new entry with the specified content)
  • everlog://newEntry?content=Hello%20world&journal=Work (Specifying a journal)
  • everlog://newEntry?content=Hello%20world&journal=Work&editor=true (Adding the editor=true parameter opens the editor and brings up the keyboard in iOS)
  • everlog://newEntry?content=Hello&date=2023-02-21 (Specify the date)
  • everlog://newEntry?content=Hello&date=2023-02-21T12:34:00 (Specify date and time)

Other URLs:

  • everlog://entry/ENTRYID (opens an entry, to get the URL for an entry right-click or long-press on an entry in the timeline and select "Copy link to entry"
  • everlog://journal/JOURNALNAME (opens a journal, for example everlog://journal/personal
everlog://entry/ENTRYID (opens an entry, to get the URL for an entry right-click or long-press on an entry in the timeline and select "Copy link to entry"
everlog://journal/JOURNALNAME (opens a journal, for example everlog://journal/personal
everlog://tag/TAGNAME (opens a tag, for example everlog://tag/weekly
everlog://onthisday (opens the On This Day screen)
everlog://settings/SCREEN (opens a settings screen, for example everlog://settings/general ). The screen possibilities are privacy, notifications, appearance, general, sync, backup, import, export, goals, templates, and premium.
everlog://sidebar (opens the menu/sidebar on iOS)
To create entries:
everlog://newEntry?editor=true (Creates a new blank entry and opens it in the editor)
everlog://newEntry?content=Hello%20world (Creates a new entry with the specified content)