<commit_before>//
//  NSColorExtensions.swift
//  Outlander
//
//  Created by <NAME> on 4/1/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import Foundation

extension NSColor {
    
    convenience init(hex:String) {
        var str = hex
        if(str.hasPrefix("#")) {
            str = hex.substringFromIndex(advance(hex.startIndex, 1))
        }
        var rgbValue:UInt32 = 0
        NSScanner(string: str).scanHexInt(&rgbValue)
        
        self.init(
            red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
            green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
            blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
            alpha: CGFloat(1.0)
        )
    }
    
    convenience init(red: Int, green: Int, blue: Int) {
        assert(red >= 0 && red <= 255, "Invalid red component")
        assert(green >= 0 && green <= 255, "Invalid green component")
        assert(blue >= 0 && blue <= 255, "Invalid blue component")
        
        self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1.0)
    }
    
    convenience init(netHex:Int) {
        self.init(red:(netHex >> 16) & 0xff, green:(netHex >> 8) & 0xff, blue:netHex & 0xff)
    }
}<commit_msg>Add hex string method to color extensions.<commit_after>//
//  NSColorExtensions.swift
//  Outlander
//
//  Created by <NAME> on 4/1/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import Foundation

extension NSColor {
    
    convenience init(hex:String) {
        var str = hex
        if(str.hasPrefix("#")) {
            str = hex.substringFromIndex(advance(hex.startIndex, 1))
        }
        var rgbValue:UInt32 = 0
        NSScanner(string: str).scanHexInt(&rgbValue)
        
        self.init(
            red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
            green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
            blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
            alpha: CGFloat(1.0)
        )
    }
    
    convenience init(red: Int, green: Int, blue: Int) {
        assert(red >= 0 && red <= 255, "Invalid red component")
        assert(green >= 0 && green <= 255, "Invalid green component")
        assert(blue >= 0 && blue <= 255, "Invalid blue component")
        
        self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1.0)
    }
    
    convenience init(netHex:Int) {
        self.init(red:(netHex >> 16) & 0xff, green:(netHex >> 8) & 0xff, blue:netHex & 0xff)
    }
    
    func getHexString() -> String {
        let red = Int(round(self.redComponent * 0xFF))
        let grn = Int(round(self.greenComponent * 0xFF))
        let blu = Int(round(self.blueComponent * 0xFF))
        let hexString = NSString(format: "#%02X%02X%02X", red, grn, blu)
        return hexString as String
    }
}
{'fraction_non_alphanumeric': 0.14640111809923131, 'fraction_numerical': 0.05625436757512229, 'mean_word_length': 2.1565600882028666, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 30, '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': '3503437', 'n_tokens_mistral': 1092, 'n_tokens_neox': 965, 'n_words': 230}