<commit_before>//
//  ViewController.swift
//  imbk
//
//  Created by <NAME> on 10/05/2016.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import UIKit
import Photos

class ViewController: UIViewController {
    @IBOutlet weak var host: UITextField!
    @IBOutlet weak var username: UITextField!
    @IBOutlet weak var password: UITextField!
    @IBOutlet weak var statusLabel: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
        self.statusLabel.text = ""
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func backupPhotos(sender: UIButton) {
        let assets = PHAsset.fetchAssetsWithMediaType(PHAssetMediaType.Image, options: nil)

        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
            assets.enumerateObjectsUsingBlock { (obj, idx, bool) -> Void in
                let asset = obj as! PHAsset
                PHImageManager.defaultManager().requestImageDataForAsset(asset, options: nil)
                    {
                        imageData,dataUTI,orientation,info in self.uploadPhoto(imageData!, index: idx, totalNumber: assets.count, creationDate: asset.creationDate!)
                }
            }
        }
    }

    func uploadPhoto(imageData: NSData, index: Int, totalNumber: Int, creationDate: NSDate) {
        dispatch_async(dispatch_get_main_queue()) {
            self.statusLabel.text = "Uploading: " + String(index + 1) + "/" + String(totalNumber)<commit_msg>Fix status label.<commit_after>//
//  ViewController.swift
//  imbk
//
//  Created by <NAME> on 10/05/2016.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import UIKit
import Photos

extension PHFetchResult: SequenceType {
    public func generate() -> NSFastGenerator {
        return NSFastGenerator(self)
    }
}

class ViewController: UIViewController {
    @IBOutlet weak var host: UITextField!
    @IBOutlet weak var username: UITextField!
    @IBOutlet weak var password: <PASSWORD>extField!
    @IBOutlet weak var statusLabel: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
        self.statusLabel.text = ""
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func backupPhotos(sender: UIButton) {
        let assets = PHAsset.fetchAssetsWithMediaType(PHAssetMediaType.Image, options: nil)

        dispatch_async(dispatch_get_global_queue(Int(QOS_CLASS_USER_INITIATED.rawValue), 0)) {
            var counter = 0;

            for asset in assets {
                counter++;
                let asset = asset as! PHAsset

                // This request must be synchronous otherwise the resultHandler ends up back on the main thread.
                let myOptions = PHImageRequestOptions()
                myOptions.synchronous = true

                PHImageManager.defaultManager().requestImageDataForAsset(asset, options: myOptions, resultHandler:
                    {
                        imageData,dataUTI,orientation,info in
                        self.uploadPhoto(imageData!, index: counter, totalNumber: assets.count, creationDate: asset.creationDate!)
                })
            }
        }
    }

    func uploadPhoto(imageData: NSData, index: Int, totalNumber: Int, creationDate: NSDate) {
        dispatch_async(dispatch_get_main_queue()) {
            self.statusLabel.text = "Uploading: " + String(index) + "/" + String(totalNumber)
{'fraction_non_alphanumeric': 0.0914380714879468, 'fraction_numerical': 0.0077583818232197285, 'mean_word_length': 2.5392156862745097, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2727691', 'n_tokens_mistral': 1052, 'n_tokens_neox': 971, 'n_words': 248}