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
| /** Delay execution until status bar Network Activity is completed | |
| {} | |
| */ | |
| automation.afterNetworkActivityEnds = function(args, cbk) { | |
| var statusBar = target.frontMostApp().statusBar(); | |
| var predicate = "name beginswith 'Network'"; | |
| while (statusBar.elements().firstWithPredicate(predicate).isValid()) { | |
| UIALogger.logMessage("Waiting for network"); |
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
| /** Strip minutes and seconds from a date | |
| */ | |
| func hourFloorFromDate(date: NSDate) -> NSDate? { | |
| let calendar: NSCalendar | |
| if let c = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian) { calendar = c } else { return nil } | |
| let units = NSCalendarUnit.CalendarUnitYear | .CalendarUnitMonth | .CalendarUnitDay | .CalendarUnitHour | |
| return calendar.dateFromComponents(calendar.components(units, fromDate: date)) |
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
| // | |
| // TableModifications.swift | |
| // mn_ios | |
| // | |
| // Created by Alex Bosworth on 4/8/15. | |
| // Copyright (c) 2015 adylitica. All rights reserved. | |
| // | |
| import UIKit |
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
| // Find the index of the first element found in a collection | |
| func findInCollection<T: CollectionType where T.Generator.Element: Equatable>(collection: T, val: T.Generator.Element...) -> T.Index? { | |
| for v in val { if let index = find(collection, v) { return index } } | |
| return nil | |
| } |
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
| var (hue, saturation, brightness, alpha) = (CGFloat(0.0), CGFloat(0.0), CGFloat(0.0), CGFloat(0.0)) | |
| let originalColor = UIColor.redColor() | |
| if originalColor.getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: &alpha) { | |
| let grayscale = UIColor(hue: hue, saturation: 0, brightness: brightness, alpha: alpha) | |
| } |
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
| func localizedStringForNumber(number: Int) -> String { | |
| let numberFormatter = NSNumberFormatter() | |
| numberFormatter.locale = NSLocale.currentLocale() | |
| numberFormatter.numberStyle = .NoStyle | |
| return numberFormatter.stringFromNumber(number) ?? String(number) | |
| } |
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 | |
| /** Helper methods for CGAffineTransform | |
| */ | |
| extension CGAffineTransform { | |
| /** Make a vertical flip transformation | |
| */ | |
| static func flipVertical() -> CGAffineTransform { | |
| return CGAffineTransformMakeScale(1, -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
| import UIKit | |
| /** Alert controller that can be presented in any context and it will appear on top | |
| */ | |
| class GlobalAlertController: UIAlertController { | |
| // MARK: - Properties (Private Mutable) | |
| /** Window to present alert controller in | |
| */ | |
| private lazy var _window: UIWindow = { |
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
| //: Bitcoin Script Interpreter | |
| import Foundation | |
| /** Script Operation | |
| */ | |
| enum Operation { | |
| case checkMultisig | |
| case checkSig | |
| case dup |
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
| package main | |
| import ( | |
| "fmt" | |
| "math" | |
| ) | |
| func Sqrt(x float64) float64 { | |
| guess := 1.0 |