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
| require 'prime' | |
| PRIMES = Prime.first(1000) | |
| # Kevin Ryde pointed out that A337724 corresponds to this formula, with crazy rounding | |
| # prime(n) - prime(n-2)/2 + prime(n-4)/2^2 - prime(n-6)/2^3 + ... | |
| # What about A337723, does it have a similar formula, with crazy rounding? | |
| # Yes, I think I have found a formula that can do it. | |
| accumulator_a = 0.5 | |
| accumulator_b = 1 |
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
| require 'prime' | |
| PRIMES = Prime.first(1000) | |
| # Kevin Ryde pointed out that A337724 corresponds to this formula, with crazy rounding | |
| # prime(n) - prime(n-2)/2 + prime(n-4)/2^2 - prime(n-6)/2^3 + ... | |
| values = [0, 1] | |
| 30.times do |i| | |
| sum = 0 | |
| power = 0 | |
| sign = 1 |
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
| # Mesolabe Compass and Square Roots - Numberphile | |
| # https://www.youtube.com/watch?v=9VVPBS_flOI | |
| v=4; Math.sin(Math.acos(2.0 / (v + 1) - 1.0)) * (v + 1) / 2.0 | |
| # 2.0000000000000004 | |
| v=9; Math.sin(Math.acos(2.0 / (v + 1) - 1.0)) * (v + 1) / 2.0 | |
| # 3.0 | |
| v=16; Math.sin(Math.acos(2.0 / (v + 1) - 1.0)) * (v + 1) / 2.0 |
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 © 2019 Simon Strandgaard. All rights reserved. | |
| import SwiftyBeaver | |
| public let log = SwiftyBeaver.self | |
| extension BaseDestination.LevelColor { | |
| mutating func applyDefaultStyle() { | |
| debug = "🏐 " | |
| info = "🏐 " | |
| verbose = "🏐 " |
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 | |
| import PlaygroundSupport | |
| /// A thread-safe array. | |
| public class SynchronizedArray<Element> { | |
| fileprivate let queue = DispatchQueue(label: "io.zamzam.ZamzamKit.SynchronizedArray", attributes: .concurrent) | |
| fileprivate var array = [Element]() | |
| } | |
| // MARK: - Properties |
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 PerfectHTTP | |
| class HandlerContext { | |
| let request: HTTPRequest | |
| let response: HTTPResponse | |
| init(request: HTTPRequest, response: HTTPResponse) { | |
| self.request = request | |
| self.response = response | |
| } |
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 UIViewController { | |
| /// Taken from this great StackOverflow post by Phani Sai: https://stackoverflow.com/a/35473300/78336 | |
| func configureChildViewController(_ childController: UIViewController, onView: UIView?) { | |
| var holderView = self.view | |
| if let onView = onView { | |
| holderView = onView | |
| } | |
| addChildViewController(childController) |
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
| let value0 = _tv(100) | |
| let value1 = _tv(200) | |
| print("the values are: \(value0) \(value1)") | |
| if _tv(1) > 0.5 { | |
| print("if-case") | |
| } else { | |
| print("else-case") | |
| } |
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
| #!/usr/bin/env ruby | |
| require 'fileutils' | |
| PATH_PG_DUMP = "/usr/lib/postgresql/9.6/bin/pg_dump" | |
| POSTGRES_HOST = "demoscene.t1qwy5zz3sn3.eu-southwest-3.rds.amazonaws.com" | |
| POSTGRES_PORT = 1234 | |
| POSTGRES_USERNAME = "admin" | |
| POSTGRES_PASSWORD = "doesnt look like anything to me" | |
| POSTGRES_DBNAME = "main" | |
| AWS_S3_BUCKET = "there.is.no.spoon" |
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 XCTest | |
| class URLRelativePathFromTests: XCTestCase { | |
| func process(_ p1: String, _ p2: String) -> String? { | |
| let u1 = URL(fileURLWithPath: p1) | |
| let u2 = URL(fileURLWithPath: p2) | |
| return u1.relativePath(from: u2) | |
| } | |
| func testNormal() { |