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 python3 | |
| """ | |
| race_probe.py — Reproduces the AuthOperationQueue /token race condition. | |
| Fires N parallel POST /token requests with the *same* refresh token and | |
| X-Idempotency-Key. A correctly serialised client never does this, but the | |
| unsynchronised AuthOperationQueue can. If the server-side idempotency cache | |
| has a write window, requests that arrive before it is populated bypass | |
| deduplication and get invalid_grant. |
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 TableController<EntityType: NSManagedObject>: NSObject, UITableViewDataSource, UITableViewDelegate, NSFetchedResultsControllerDelegate { | |
| let tableView: UITableView | |
| let managedObjectContext: NSManagedObjectContext | |
| let fetchRequest: NSFetchRequest<EntityType> | |
| let cellIdentifier: String | |
| let configureCell: (UITableViewCell, EntityType) -> Void | |
| init(tableView: UITableView, managedObjectContext: NSManagedObjectContext, fetchRequest: NSFetchRequest<EntityType>, cellIdentifier: String, configureCell: @escaping (UITableViewCell, EntityType) -> Void) { | |
| self.tableView = tableView | |
| self.managedObjectContext = managedObjectContext |
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 Book { | |
| let title: String | |
| } | |
| protocol SegueHandling { | |
| func handle(segue: UIStoryboardSegue) -> Bool | |
| } | |
| struct SegueHandler<ViewControllerType>: SegueHandling { | |
| let identifier: String |
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 nodes = document.getElementsByName("qty[]"); | |
| var index; | |
| for (index = 0; index < nodes.length; ++index) { | |
| var node = nodes[index]; | |
| if (node.getAttribute("title") == "Task hours") { | |
| var nonRoundedValueAsString = node.getAttribute("value"); | |
| var nonRoundedValue = Number(nonRoundedValueAsString); | |
| var roundedValue = (Math.round(nonRoundedValue * 4) / 4).toFixed(2); | |
| console.log(nonRoundedValue + " => " + roundedValue); | |
| node.value = roundedValue.toString(); |
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
| @UIApplicationMain | |
| class AppDelegate: UIResponder, UIApplicationDelegate { | |
| lazy var window: UIWindow? = { | |
| let window = UIWindow(frame: UIScreen.mainScreen().bounds) | |
| window.backgroundColor = UIColor.whiteColor() | |
| window.rootViewController = ViewController() | |
| return window | |
| }() | |
| func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { |
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/UIKit.h> | |
| @interface LoadingView : UIView | |
| @property (nonatomic, weak, readonly) UILabel *loadingLabel; | |
| @property (nonatomic, weak, readonly) UIActivityIndicatorView *activityIndicator; | |
| @end |
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
| path = ‘/path/to/music/folder’ | |
| puts "Renaming files..." | |
| Dir.foreach(path) do |item| | |
| next if item == '.' or item == '..' | |
| new_name = File.basename(item, ".*") | |
| # car works better with a-z 0-9 A-Z only |
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
| # Needs to be placed after the usual versioning script in the WatchKit extension to copy the extension’s build number over to the app. | |
| extension_plist="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" | |
| extension_build_path="${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}" | |
| app_name=`cd "$extension_build_path"; ls -d *app` | |
| app_plist="${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}/$app_name/Info.plist" | |
| extension_build_number=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "$extension_plist") | |
| /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $extension_build_number" "$app_plist" |
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
| if [ ${CONFIGURATION} == "AppStore" ]; then | |
| buildNumber=$(git rev-list HEAD | wc -l | tr -d ' ') | |
| /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/AppName/AppName-Info.plist" | |
| /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/AppName WatchKit App/Info.plist" | |
| /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/AppName WatchKit Extension/Info.plist" | |
| fi; | |
| if [ ${CONFIGURATION} == "Release" ]; then | |
| buildNumber=$(git rev-list HEAD | wc -l | tr -d ' ') | |
| /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/AppName/AppName-Info.plist" |
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 | |
| /** Custom subclass of UISearchDisplayController that overrides the default behaviour of hiding the navigation bar when becoming active. */ | |
| class SearchDisplayController: UISearchDisplayController { | |
| override func setActive(visible: Bool, animated: Bool) { | |
| if self.active == visible { | |
| return | |
| } | |
| searchContentsController.edgesForExtendedLayout = .Bottom |
NewerOlder