This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.swift | |
// COW Example | |
// | |
// Created by The Northstar✨ System on 2023-10-16. | |
// | |
import Foundation | |
struct Person { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public extension Array where Element == UInt8 { | |
// MARK: - Constants | |
/// This is used by the `toHexString()` method | |
private static let uppercaseHexCharacters : [Character] = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BLUE HUSKY LICENSE 0 - PUBLIC DOMAIN - OPUS 7 | |
0: LAYMAN'S TERMS | |
This section is meant to explain the purpose of this License in Layman's | |
terms, and should thusly never be seen as legally binding. This disclaimer does | |
not apply to further sections of this License. | |
1. This is no one's product and is in the public domain | |
2. You're not responsible for any bad things that might happen because someone | |
used this product |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// By Ben Leggiero on 2019-05-07 | |
// License is BH-1-PS: https://github.com/BlueHuskyStudios/Licenses/blob/master/Licenses/BH-1-PS.txt | |
import AppKit | |
public extension NSAnimationContext { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Exception from standalone Kotlin compiler> | |
Kotlin: [Internal Error] org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: wrong code generated | |
org.jetbrains.kotlin.codegen.CompilationException Back-end (JVM) Internal error: Couldn't transform method node: | |
reposition (Lorg/bh/tools/base/math/geometry/FractionRect;Lorg/bh/tools/base/math/geometry/FractionRect;)Lorg/bh/tools/base/math/geometry/FractionRect;: | |
@Lorg/jetbrains/annotations/NotNull;() // invisible | |
@Lorg/jetbrains/annotations/NotNull;() // invisible, parameter 0 | |
@Lorg/jetbrains/annotations/NotNull;() // invisible, parameter 1 | |
L0 | |
ALOAD 1 | |
LDC "rect" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Array where Iterator.Element == String { | |
/// Originally by Cortis Clark on StackOverflow, modified by Ben Leggiero for an example | |
/// - SeeAlso: https://stackoverflow.com/a/52266604/3939277 | |
func joinedWithComma(useOxfordComma: Bool = true, maxItemCount: UInt8? = nil) -> String { | |
let result: String | |
if let maxItemCount = maxItemCount, count > maxItemCount { | |
result = self[0 ..< maxItemCount].joined(separator: ", ") + ", etc." | |
} else if count >= 2 { | |
let lastIndex = count - 1 | |
let extraComma = (useOxfordComma && count > 2) ? "," : "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
private func gainPermissions() { | |
var authorizationRef: AuthorizationRef? = nil | |
var authItem = AuthorizationItem(name: kSMRightBlessPrivilegedHelper, valueLength: 0, value: nil, flags: 0) | |
var authRights = AuthorizationRights(count: 1, items: &authItem) | |
let flags: AuthorizationFlags = [.interactionAllowed, .preAuthorize, .extendRights] | |
var environment = AuthorizationEnvironment() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Uses quicksort with the Lomuto partition scheme. | |
/// | |
/// By Ben Leggiero, written on 2018-03-05. Copyright BH-0-PD | |
/// https://github.com/BlueHuskyStudios/Licenses/blob/master/Licenses/BH-0-PD.txt | |
struct QuickSorter { | |
/// Performs a quicksort with Lomuto partition using the given array and returns the result | |
func quicksorting<C: Comparable>(_ unsorted: [C]) -> [C] { | |
var arrayCopy = unsorted | |
QuickSorter.quicksort(&arrayCopy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// This file is an illustration of the concepts described in the Computerphile video "What is a Monad?", but in Swift rather than the video's Haskell. | |
/// https://www.youtube.com/watch?v=t1e8gqXLbsU | |
import Cocoa | |
// MARK: - Stuff we need in order to make our code look like the code in the video |
NewerOlder