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 | |
@propertyWrapper | |
struct Clapping<Value: Comparable> { | |
var value: Value | |
let range: ClosedRange<Value> | |
init(wrappedValue: Value, _ range: ClosedRange<Value>) { | |
precondition(range.contains(wrappedValue)) |
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
require 'plist' | |
require 'ostruct' | |
require 'base64' | |
require 'json' | |
fixedPath = "Test-NewDangerSnapshotting-2019.06.15_19-52-13-+0100.xcresult" | |
class XCResult | |
attr_reader :reference, :tests |
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 UIKit | |
struct DiffLine: CustomDebugStringConvertible { | |
enum DiffLineType { | |
case equal | |
case remove | |
case add | |
case replace | |
} |
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
func create<T: UIView>(usingAutoLayout: Bool = true, configure: (T) -> Void) -> T { | |
let object = T() | |
object.translatesAutoresizingMaskIntoConstraints = !usingAutoLayout | |
configure(object) | |
return object | |
} |
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 | |
enum LinkType: FormatterUrl { | |
case product(String) | |
case look(String) | |
func formatter(prefix: String) -> String { | |
switch self { | |
case .product(let id): return prefix.appending("://products/\(id)") | |
case .look(let id): return prefix.appending("://looks?order=1&collections=\(id)") |
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 | |
func kadaneSumMaxSubArray(_ values: [Int]) -> Int { | |
guard let firstValue = values.first else { return 0} | |
var current = firstValue | |
var global = firstValue | |
for value in values[1 ..< values.count] { | |
current = (current + value) < current ? 0 : current | |
current = max(current, (current + value)) | |
global = max(global, current) |
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 | |
let str = "aabbaaccccdaeeeebb" | |
func compressString(_ value: String) -> String { | |
var resultStr = "" | |
var currentChar: Character? | |
var currentCount: Int = 0 | |
for c in value { | |
guard let char = currentChar 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
import Cocoa | |
indirect enum BinaryTree<T> { | |
case node(BinaryTree, T, BinaryTree) | |
case empty | |
} | |
extension BinaryTree { | |
static func leaf(_ value: T) -> BinaryTree { | |
return .node(.empty,value,.empty) |
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 | |
struct CircularQueueIterator<T>: IteratorProtocol { | |
let queue: [T] | |
private var position = 0 | |
init(queue: [T]) { | |
self.queue = queue | |
} |
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 | |
indirect enum BinaryTree<T> { | |
case node(BinaryTree, T, BinaryTree) | |
case empty | |
} | |
extension BinaryTree { | |
static func leaf(_ value: T) -> BinaryTree { |
NewerOlder