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
| /* | |
| The MIT License (MIT) | |
| Copyright (c) 2010 Blixt | |
| Permission is hereby granted, free of charge, to any person obtaining a copy of | |
| this software and associated documentation files (the "Software"), to deal in | |
| the Software without restriction, including without limitation the rights to | |
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
| the Software, and to permit persons to whom the Software is furnished to do so, |
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
| #=============================================================================# | |
| # dieharder version 3.31.1 Copyright 2003 Robert G. Brown # | |
| #=============================================================================# | |
| rng_name | filename |rands/second| | |
| file_input| dieharder.txt| 4.17e+06 | | |
| #=============================================================================# | |
| test_name |ntup| tsamples |psamples| p-value |Assessment | |
| #=============================================================================# | |
| diehard_birthdays| 0| 100| 100|0.80634484| PASSED | |
| diehard_operm5| 0| 1000000| 100|0.02613178| PASSED |
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
| #=============================================================================# | |
| # dieharder version 3.31.1 Copyright 2003 Robert G. Brown # | |
| #=============================================================================# | |
| rng_name | filename |rands/second| | |
| file_input| dieharder.txt| 4.11e+06 | | |
| #=============================================================================# | |
| test_name |ntup| tsamples |psamples| p-value |Assessment | |
| #=============================================================================# | |
| diehard_birthdays| 0| 100| 100|0.37793720| PASSED | |
| diehard_operm5| 0| 1000000| 100|0.25454738| PASSED |
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
| #=============================================================================# | |
| # dieharder version 3.31.1 Copyright 2003 Robert G. Brown # | |
| #=============================================================================# | |
| rng_name | filename |rands/second| | |
| file_input| dieharder.txt| 4.31e+06 | | |
| #=============================================================================# | |
| test_name |ntup| tsamples |psamples| p-value |Assessment | |
| #=============================================================================# | |
| diehard_birthdays| 0| 100| 100|0.15936729| PASSED | |
| diehard_operm5| 0| 1000000| 100|0.95725635| PASSED |
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
| class ListDiff<T : Hashable> { | |
| typealias IndexList = [Int] | |
| typealias FromIndexToIndexList = [(from: Int, to: Int)] | |
| // A list of indexes of where items were added. | |
| let added: IndexList | |
| // A list of indexes where items that have disappeared used to be. | |
| let deleted: IndexList | |
| // A list of tuples of indexes representing the old and new indexes of items that moved. | |
| let moved: FromIndexToIndexList |
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
| struct OrderedDictionary<Key : Hashable, Value> { | |
| typealias Element = (key: Key, value: Value) | |
| private var dictionary = [Key: Value]() | |
| private var orderedKeys = [Key]() | |
| var count: Int { | |
| return self.orderedKeys.count | |
| } |
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
| // Update: See a solution here: | |
| // https://gist.github.com/blixt/08434b74f0c043f83fcb | |
| // (NSMapTable holds onto the weak keys longer than I expected) | |
| import Foundation | |
| private class ClosureWrapper<EventData> { | |
| typealias EventHandler = (EventData) -> Void | |
| let closure: EventHandler | |
| init(_ closure: EventHandler) { |
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 | |
| private class Invoker<EventData> { | |
| weak var listener: AnyObject? | |
| let closure: (EventData) -> Bool | |
| init<Listener : AnyObject>(listener: Listener, method: (Listener) -> (EventData) -> Void) { | |
| self.listener = listener | |
| self.closure = { | |
| [weak listener] (data: EventData) in |
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
| function format(strings, ...values) { | |
| const pieces = []; | |
| for (let [index, string] of strings.entries()) { | |
| let value = values[index]; | |
| const formatIndex = string.lastIndexOf('$'); | |
| if (formatIndex != -1) { | |
| const format = string.substr(formatIndex + 1); | |
| string = string.substr(0, formatIndex); | |
| // TODO: Use an actual format engine here. |
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 UIKit | |
| extension String { | |
| var hexColor: UIColor? { | |
| let hex = self.stringByTrimmingCharactersInSet(NSCharacterSet.alphanumericCharacterSet().invertedSet) | |
| var int = UInt32() | |
| guard NSScanner(string: hex).scanHexInt(&int) else { | |
| return nil | |
| } | |
| let a, r, g, b: UInt32 |