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
// | |
// Range+Extensions.swift | |
// IntensityAttributingKit | |
// | |
// Created by Evan Mckee on 3/23/16. | |
// Copyright © 2016 McKeeMaKer. All rights reserved. | |
// | |
import Foundation |
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 | |
/*Range*/ | |
let a:Range<Int> = 1..<3 | |
print(type(of:a))//Range<Int> | |
a.upperBound//3 | |
/*ClosedRange*/ | |
let b:ClosedRange<Int> = 1...3 | |
print(type(of:b))//ClosedRange<Int> |
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 | |
/** | |
* EXAMPLE: Range(start:2,end:6).count//4 | |
*/ | |
extension Range { | |
/** | |
* EXAMPLE: Range<Int>(0,3).numOfIndecies()//4 -> because [0,1,2,3].count// 4 | |
* NOTE: only works with Range<Int> for now | |
*/ | |
init(_ start:Bound,_ end:Bound){/*Conveninence initializer*/ |
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 AppKit | |
import XCPlayground | |
import Cocoa | |
import PlaygroundSupport | |
extension NSLayoutConstraint { | |
convenience init(view item: NSView, to toItem: NSView, attribute: NSLayoutAttribute, constant c: CGFloat = 0) { | |
self.init(item: item, attribute: attribute, | |
relatedBy: .equal, | |
toItem: toItem, attribute: attribute, |
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 Cocoa | |
import XCPlayground | |
import PlaygroundSupport | |
@testable import MyFrameWork | |
class TouchView: NSView { | |
var (path, currentPath) = (NSBezierPath(), NSBezierPath()) | |
override var isFlipped:Bool {return true}/*Organizes your view from top to bottom*/ | |
override init(frame frameRect: NSRect) { |
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
/*Assert methods*/ | |
class RangeAsserter{ | |
static func equals(_ a: IRange, _ b:IRange) -> Bool { | |
return a.start == b.start && a.end == b.end | |
} | |
} | |
/*Parser methods*/ | |
class RangeParser{ | |
static func length(_ range:IRange) -> Int { |
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
//: Playground - noun: a place where people can play | |
import Cocoa | |
import PlaygroundSupport | |
@testable import MyFramework | |
//Temp.test() | |
@testable import Utils | |
@testable import Element |
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
//forked from: https://github.com/BergQuester/Interactive-Window-Swift-Playground | |
import Cocoa | |
import XCPlayground | |
// Window size | |
let windowRect = NSRect(x: 30, y: 30, width: 300, height: 300) | |
var window = NSWindow(contentRect: NSRect(x: 30, y: 30, width: 300, height: 300), styleMask: NSWindowStyleMask.titled, backing: .buffered, defer: false) |
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
protocol AnyArray{}/*<--Neat trick to assert if a value is an Array, use-full in reflection and when the value is Any but really an array*/ | |
extension Array:AnyArray{}//Maybe rename to ArrayType | |
func recFlatMap<T>(_ arr:[AnyObject]) -> [T]{ | |
var result:[T] = [] | |
Swift.print("arr.count: " + "\(arr.count)") | |
arr.forEach{ | |
if($0 is AnyArray){ | |
let a:[AnyObject] = $0 as! [AnyObject] | |
result += recFlatMap(a) | |
}else{ |
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 URLRequest { | |
/// The cURL representation of the URLRequest, useful for debugging and executing requests outside of the app. | |
var cURLCommand: String { | |
var command = "curl" | |
if let httpMethod = httpMethod { | |
command.append(commandLineArgument: "-X \(httpMethod)") | |
} |