<commit_before>
import UIKit

class ViewController: UIViewController {
    
    @IBOutlet var startTimeLabel: UILabel!
    @IBOutlet var elapsedTimeLabel: UILabel!
    @IBOutlet var startDoneButton: UIButton!
    
    private var isRunning = false
    private var startDate: Date?
    private var heartbeatTimer: Timer?
    
    private let dateFormatter = DateFormatter()
    
    private func start() {
        isRunning = true
        startDate = Date()

        startTimeLabel.isHidden = false
        elapsedTimeLabel.isHidden = false

        startTimer()
    }
    
    private func stop() {
        isRunning = false
        stopTimer()
    }
    
    
    private func startTimer() {
        // Should not be starting a timer that's already started.
        precondition(heartbeatTimer == nil)
        
        // I run iOS 9 on my precioussss gold 5s.  The nice block version of scheduledTimer came in iOS10.
        heartbeatTimer = Timer.scheduledTimer(timeInterval: 0.5, 
                                              target: self, 
                                              selector: #selector(self.lubdub), 
                                              userInfo: nil, 
                                              repeats: true)
    }
    
    private func stopTimer() {
        // Should not be stopping a timer that's not started
        precondition(heartbeatTimer != nil)
        
        heartbeatTimer?.invalidate()
        heartbeatTimer = nil
    }
    

    // Timer callback
    @objc private func lubdub() {
        precondition(startDate != nil)
        precondition(isRunning)
        
        updateElapsedTimeLabel()
    }
    
    private func updateElapsedTimeLabel() {
        guard let startDate = startDate else {
            elapsedTimeLabel.text = "0:00:00"
            return   
        }
        let time = abs(startDate.timeIntervalSinceNow)
        elapsedTimeLabel.text = time.HHMMSS()
    }<commit_msg>Plays a subtle _tink_ sound when you hit 30 minutes<commit_after>import UIKit
import AudioToolbox

class ViewController: UIViewController {
    
    @IBOutlet var startTimeLabel: UILabel!
    @IBOutlet var elapsedTimeLabel: UILabel!
    @IBOutlet var startDoneButton: UIButton!
    
    private var isRunning = false
    private var startDate: Date?
    private var heartbeatTimer: Timer?
    private var didPing = false
    
    private let pingThreshold: TimeInterval = 30 * 60  // half hour of solid focused work
    
    private let dateFormatter = DateFormatter()
    
    private func elapsedTime() -> TimeInterval {
        guard let startDate = startDate else { return 0 }
        let time = abs(startDate.timeIntervalSinceNow)
        return time
    }
    
    private func ping() {
        AudioServicesPlaySystemSound(1057) // Tink - In honor of <NAME>
    }
    
    private func maybePing() {
        guard !didPing else { return }
        
        if elapsedTime() > pingThreshold {
            ping()   
            didPing = true
        }
    }
    
    private func start() {
        isRunning = true
        startDate = Date()

        startTimeLabel.isHidden = false
        elapsedTimeLabel.isHidden = false

        startTimer()
    }
    
    private func stop() {
        isRunning = false
        stopTimer()
    }
    
    
    private func startTimer() {
        // Should not be starting a timer that's already started.
        precondition(heartbeatTimer == nil)
        
        // I run iOS 9 on my precioussss gold 5s.  The nice block version of scheduledTimer came in iOS10.
        heartbeatTimer = Timer.scheduledTimer(timeInterval: 0.5, 
                                              target: self, 
                                              selector: #selector(self.lubdub), 
                                              userInfo: nil, 
                                              repeats: true)
    }
    
    private func stopTimer() {
        // Should not be stopping a timer that's not started
        precondition(heartbeatTimer != nil)
        
        heartbeatTimer?.invalidate()
        heartbeatTimer = nil
    }
    

    // Timer callback
    @objc private func lubdub() {
        precondition(startDate != nil)
        precondition(isRunning)

        maybePing()
        updateElapsedTimeLabel()
    }
    
    private func updateElapsedTimeLabel() {
        guard let startDate = startDate else {
            elapsedTimeLabel.text = "0:00:00"
            return   
        }
        elapsedTimeLabel.text = elapsedTime().HHMMSS()
    }
{'fraction_non_alphanumeric': 0.06709194896612407, 'fraction_numerical': 0.007259128904531456, 'mean_word_length': 1.6436046511627906, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4305858', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1144, 'n_words': 338}