This file contains hidden or 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
// Made to answer http://stackoverflow.com/questions/38512761/how-do-i-find-the-x-y-coordinates-of-the-point-q-on-a-closed-2d-composite-bez | |
struct BezierPoint { | |
let q0: CGPoint | |
let point: CGPoint | |
let q1: CGPoint | |
} | |
struct SimpleBezierCurve { | |
let left: BezierPoint |
This file contains hidden or 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
// Copyright Ben Leggiero 2017 BH-1-PS | |
// https://github.com/BlueHuskyStudios/Licenses/blob/master/Licenses/BH-1-PS.txt | |
import Foundation | |
This file contains hidden or 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
Control: | |
file:/// => file:/// | |
file:///etc/ => file:///etc/ | |
~/ -- file:/// => ~/ -- file:/// | |
~/Desktop -- file:/// => ~/Desktop -- file:/// | |
~/.bash_profile -- file:/// => ~/.bash_profile -- file:/// | |
./ -- file:/// => ./ -- file:/// | |
../ -- file:/// => ../ -- file:/// | |
file:///etc/../ => file:///etc/../ | |
~/../ -- file:/// => ~/../ -- file:/// |
This file contains hidden or 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
/// Example type | |
public struct Foo { | |
// Fields... | |
} | |
/// Wraps `Foo` so it can be used for that static variable later | |
private struct FooWrapper { |
This file contains hidden or 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 Cocoa | |
public extension NSApplication { | |
public func relaunch(afterDelay seconds: TimeInterval = 0.5) -> Never { | |
let task = Process() | |
task.launchPath = "/bin/sh" | |
task.arguments = ["-c", "sleep \(seconds); open \"\(Bundle.main.bundlePath)\""] |
This file contains hidden or 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
// | |
// Swift range conformance check.swift | |
// Requires Swift 4 | |
// | |
// Created by Ben Leggiero on 2017-11-06. | |
// Copyright © 2017 Ben Leggiero using BH-1-PS license | |
// | |
// This is a proof-of-concept that attempts to create a syntax like "left < center < right", which ensures that | |
// "center" is both greater than "left" and less than "right". |
This file contains hidden or 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
// | |
// NSWindow+Fade.swift | |
// BH Bezel Notification | |
// | |
// Created by Ben Leggiero on 2017-11-09. | |
// Translated to Swift 4 from the original (ObjC): https://gist.github.com/indragiek/1397050 | |
// Copyright © 2017 Ben Leggiero. All rights reserved. | |
// | |
import Foundation |
This file contains hidden or 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 |
This file contains hidden or 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) |
OlderNewer