A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
import Foundation | |
// Inspired by https://gist.github.com/mbuchetics/c9bc6c22033014aa0c550d3b4324411a | |
struct JSONCodingKeys: CodingKey { | |
var stringValue: String | |
init?(stringValue: String) { | |
self.stringValue = stringValue | |
} |
// Thanks to @MonsieurDart for the idea :) | |
func scroll(collectionView:XCUIElement, toFindCellWithId identifier:String) -> XCUIElement? { | |
guard collectionView.elementType == .collectionView else { | |
fatalError("XCUIElement is not a collectionView.") | |
} | |
var reachedTheEnd = false | |
var allVisibleElements = [String]() | |
while !reachedTheEnd { |
// Swift enums cannot be declared with a rawValue if they have associated values | |
// like good ol' Amargasaurus has. Using String(describing: dino) on a case with | |
// associated also includes the values, but works fine on unassociated cases. | |
// Mirror(reflecting: dino) can extract the name of an associated case, but is | |
// nil for unassociated cases. Our hero ?? swoops in to save the day! | |
enum Sauropoda { | |
case Amargasaurus(things: Int64, hasOtherThing: Bool?) | |
case Antetonitrus | |
// ... |
extension UIViewController { | |
func topMostViewController() -> UIViewController { | |
if self.presentedViewController == nil { | |
return self | |
} | |
if let navigation = self.presentedViewController as? UINavigationController { | |
return navigation.visibleViewController.topMostViewController() | |
} | |
if let tab = self.presentedViewController as? UITabBarController { | |
if let selectedTab = tab.selectedViewController { |
"""Information Retrieval metrics | |
Useful Resources: | |
http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt | |
http://www.nii.ac.jp/TechReports/05-014E.pdf | |
http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf | |
http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf | |
Learning to Rank for Information Retrieval (Tie-Yan Liu) | |
""" | |
import numpy as np |