<commit_before>//
//  Utility.swift
//  SegueingInfo
//
//  Created by <NAME> on 12/3/15.
//  Copyright © 2015 Adorkable. All rights reserved.
//

import Foundation

// TODO: Unit Test for Utility.swift
public func random_UInt32() -> UInt32
{
    return arc4random()
}

extension String {
    
    subscript (index : Int) -> Character {
        return self[ self.startIndex.advancedBy(index) ]
    }
    
    // TODO: random string without repeat
    // TODO: NSCharacterSet
    public static func randomString(length : Int, allowedCharacters : String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890") -> String {
        var result = String()
        
        for _ in 1...length
        {
            let randomCharacterIndex = Int(random_UInt32()) % allowedCharacters.characters.count
            let randomCharacter : Character = allowedCharacters[randomCharacterIndex]
            result.append(randomCharacter)
        }
        
        return result
    }
}<commit_msg>fix test crash<commit_after>//
//  Utility.swift
//  SegueingInfo
//
//  Created by <NAME> on 12/3/15.
//  Copyright © 2015 Adorkable. All rights reserved.
//

import Foundation

extension String {
    
    subscript (index : Int) -> Character {
        return self[ self.startIndex.advancedBy(index) ]
    }
    
    // TODO: random string without repeat
    // TODO: NSCharacterSet
    public static func randomString(length : Int, allowedCharacters : String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890") -> String {
        var result = String()
        
        for _ in 1...length
        {
            let randomCharacterIndex = arc4random_uniform(UInt32(allowedCharacters.characters.count))
            let randomCharacter : Character = allowedCharacters[Int(randomCharacterIndex)]
            result.append(randomCharacter)
        }
        
        return result
    }
}
{'fraction_non_alphanumeric': 0.09330521876647338, 'fraction_numerical': 0.02635740643120717, 'mean_word_length': 2.4446460980036298, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6495751', 'n_tokens_mistral': 589, 'n_tokens_neox': 541, 'n_words': 130}