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
precedencegroup AssociativeComparisonPrecedence { | |
associativity: left | |
higherThan: ComparisonPrecedence | |
lowerThan: NilCoalescingPrecedence | |
} | |
infix operator <: AssociativeComparisonPrecedence | |
infix operator <=: AssociativeComparisonPrecedence | |
public func < <V: Comparable>(lhs: V, rhs: V) -> (Bool, V) { |
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
// make equation coefficients and vectors of x and y for bezier interpolation | |
export function bezierControlsEquation(knots) { | |
// [Theory of Beizer Interpolation] | |
// bezier curve: | |
// - p(t) = (1-t)^3*P0 + 3(1-t)^2*t*C0 + 3(1-t)t^2*C1 + t^3*P1 | |
// - p(0) = P0 | |
// - p(1) = P1 | |
// - p'(t) = -3(t^2-2t+1)*P0 + 3(3t^2-4t+1)*C0 + 3(-3t^2+2t)*C1 + 3t^2*P1 | |
// - p'(0) = -3*P0 + 3*C0 | |
// - p'(1) = -3*C1 + 3*P1 |
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
// | |
// AttributedString.swift | |
// | |
// Created by fm.tonakai on 2019/04/08. | |
// | |
import UIKit | |
public struct AttributedString: ExpressibleByStringLiteral, ExpressibleByStringInterpolation, CustomStringConvertible { | |
public struct StringInterpolation: StringInterpolationProtocol { |
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
// Zipping.swift | |
// known-good: Swift 4.2 | |
// Alexis Gallagher | |
import Foundation | |
public extension URL { | |
/// Creates a zip archive of the file or folder represented by this URL and returns a references to the zipped 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
import Foundation | |
public class WeakSet<T: AnyObject>: Sequence, ExpressibleByArrayLiteral, CustomStringConvertible, CustomDebugStringConvertible { | |
private var objects = NSHashTable<T>.weakObjects() | |
public init(_ objects: [T]) { | |
for object in objects { | |
insert(object) | |
} |
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
// RationalNumber.swift | |
// | |
// A basic implementation of Rational numbers in Swift 3.0. | |
// (c) 2016 Hooman Mehr. Licensed under Apache License v2.0 with Runtime Library Exception | |
/// A data type to model rational numbers in Swift. | |
/// | |
/// It always uses fully-reduced representation for simplicity and clarity of comparisons and uses LCM |
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
// https://www.cs.rit.edu/~ncs/color/t_convert.html | |
struct RGB { | |
// Percent | |
let r: Float // [0,1] | |
let g: Float // [0,1] | |
let b: Float // [0,1] | |
static func hsv(r: Float, g: Float, b: Float) -> HSV { | |
let min = r < g ? (r < b ? r : b) : (g < b ? g : b) | |
let max = r > g ? (r > b ? r : b) : (g > b ? g : b) |
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 "UIResponder+FirstResponder.h" | |
static __weak id currentFirstResponder; | |
@implementation UIResponder (FirstResponder) | |
+ (id)currentFirstResponder | |
{ | |
currentFirstResponder = nil; | |
[[UIApplication sharedApplication] sendAction:@selector(findFirstResponder:) to:nil from:nil forEvent:nil]; |
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
#!/bin/sh | |
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal | |
# make sure the output directory exists | |
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" | |
# Step 1. Build Device and Simulator versions | |
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build | |
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build |