<commit_before>/**@license
 *       __ _____                     ________                              __
 *      / // _  /__ __ _____ ___ __ _/__  ___/__ ___ ______ __ __  __ ___  / /
 *  __ / // // // // // _  // _// // / / // _  // _//     // //  \/ // _ \/ /
 * /  / // // // // // ___// / / // / / // ___// / / / / // // /\  // // / /__
 * \___//____ \\___//____//_/ _\_  / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
 *           \/              /____/
 * http://terminal.jcubic.pl
 *
 * This is example of how to create less like command for jQuery Terminal
 * the code is based on the one from leash shell and written as jQuery plugin
 *
 * Copyright (c) 2018-2019 <NAME> <https://jcubic.pl/me>
 * Released under the MIT license
 *
 */
/* global define, global, require, module, Image, URL */
(function(factory, undefined) {
    var root = typeof window !== 'undefined' ? window : global;
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        // istanbul ignore next
        define(['jquery', 'jquery.terminal'], factory);
    } else if (typeof module === 'object' && module.exports) {
        // Node/CommonJS
        module.exports = function(root, jQuery) {
            if (jQuery === undefined) {
                // require('jQuery') returns a factory that requires window to
                // build a jQuery instance, we normalize how we use modules
                // that require this pattern but the window provided is a noop
                // if it's defined (how jquery works)
                if (window !== undefined) {
                    jQuery = require('jquery');
                } else {
                    jQuery = require('jquery')(root);
                }
            }
            if (!jQuery.fn.terminal) {
                if (window !== undefined) {
                    require('jquery.terminal');
                } else {
                    require('jquery.terminal')(jQuery);
                }
            }
            factory(jQuery);
            return jQuery;
        };
    } else {
        // Browser
        // istanbul ignore next
        factory(root.jQuery);
    }
})(function($) {
    var img_split_re = /(\[\[(?:@|[^;])*;[^;]*;[^\]]*\]\])/;
    var img_re = /\[\[(?:@|[^;])*;[^;]*;[^;]*;[^;]*;([^;]*)\]\]/;
    // slice images into terminal lines - each line is unique blob url

    function slice_image(img_data, width, y1, y2) {
        // render slice on canvas and get Blob Data URI
        var canvas = document.createElement('canvas');
        var ctx = canvas.getContext('2d');
        canvas.width = width;
        canvas.height = y2 - y1;
        ctx.putImageData(img_data, 0, 0);
        var defer = $.Deferred();
        canvas.toBlob(function(blob) {
            defer.resolve(URL.createObjectURL(blob));
        });
        return defer.promise();
    }
    function slice(src, options) {
        var settings = $.extend({
            width: null,
            line_height: null
        }, options);
        var img = new Image();
        var defer = $.Deferred();
        var slices = [];
        img.onload = function() {
            var height, width;
            if (settings.width < img.width) {
                height = (img.height * settings.width) / img.width;
                width = settings.width;
            } else {
                height = img.height;
                width = img.width;
            }
            var canvas = document.createElement('canvas');
            var ctx = canvas.getContext('2d');
            canvas.width = width;
            canvas.height = height;
            // scale the image to fit the terminal
            ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, width, height);
            (function recur(start) {
                // loop over slices
                if (start < height) {
                    var y1 = start, y2 = start + settings.line_height;
                    if (y2 > height) {
                        y2 = height;
                    }
                    var img_data = ctx.getImageData(0, y1, width, y2);
                    slice_image(img_data, width, y1, y2).then(function(uri) {
                        slices.push(uri);
                        recur(y2);
                    });
                } else {
                    defer.resolve(slices);
                }
            })(0);<commit_msg>fix float number rounding issue when rendering images in less #515<commit_after>/**@license
 *       __ _____                     ________                              __
 *      / // _  /__ __ _____ ___ __ _/__  ___/__ ___ ______ __ __  __ ___  / /
 *  __ / // // // // // _  // _// // / / // _  // _//     // //  \/ // _ \/ /
 * /  / // // // // // ___// / / // / / // ___// / / / / // // /\  // // / /__
 * \___//____ \\___//____//_/ _\_  / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
 *           \/              /____/
 * http://terminal.jcubic.pl
 *
 * This is example of how to create less like command for jQuery Terminal
 * the code is based on the one from leash shell and written as jQuery plugin
 *
 * Copyright (c) 2018-2019 <NAME> <https://jcubic.pl/me>
 * Released under the MIT license
 *
 */
/* global define, global, require, module, Image, URL */
(function(factory, undefined) {
    var root = typeof window !== 'undefined' ? window : global;
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        // istanbul ignore next
        define(['jquery', 'jquery.terminal'], factory);
    } else if (typeof module === 'object' && module.exports) {
        // Node/CommonJS
        module.exports = function(root, jQuery) {
            if (jQuery === undefined) {
                // require('jQuery') returns a factory that requires window to
                // build a jQuery instance, we normalize how we use modules
                // that require this pattern but the window provided is a noop
                // if it's defined (how jquery works)
                if (window !== undefined) {
                    jQuery = require('jquery');
                } else {
                    jQuery = require('jquery')(root);
                }
            }
            if (!jQuery.fn.terminal) {
                if (window !== undefined) {
                    require('jquery.terminal');
                } else {
                    require('jquery.terminal')(jQuery);
                }
            }
            factory(jQuery);
            return jQuery;
        };
    } else {
        // Browser
        // istanbul ignore next
        factory(root.jQuery);
    }
})(function($) {
    var img_split_re = /(\[\[(?:@|[^;])*;[^;]*;[^\]]*\]\])/;
    var img_re = /\[\[(?:@|[^;])*;[^;]*;[^;]*;[^;]*;([^;]*)\]\]/;
    // slice images into terminal lines - each line is unique blob url

    function slice_image(img_data, width, y1, y2) {
        // render slice on canvas and get Blob Data URI
        var canvas = document.createElement('canvas');
        var ctx = canvas.getContext('2d');
        canvas.width = width;
        canvas.height = y2 - y1;
        ctx.putImageData(img_data, 0, 0);
        var defer = $.Deferred();
        canvas.toBlob(function(blob) {
            defer.resolve(URL.createObjectURL(blob));
        });
        return defer.promise();
    }
    function slice(src, options) {
        var settings = $.extend({
            width: null,
            line_height: null
        }, options);
        var img = new Image();
        var defer = $.Deferred();
        var slices = [];
        img.onload = function() {
            var height, width;
            if (settings.width < img.width) {
                height = Math.floor((img.height * settings.width) / img.width);
                width = settings.width;
            } else {
                height = img.height;
                width = img.width;
            }
            var canvas = document.createElement('canvas');
            var ctx = canvas.getContext('2d');
            canvas.width = width;
            canvas.height = height;
            // scale the image to fit the terminal
            ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, width, height);
            (function recur(start) {
                // loop over slices
                if (start < height) {
                    var y1 = start, y2 = start + settings.line_height;
                    if (y2 > height) {
                        y2 = height;
                    }
                    var img_data = ctx.getImageData(0, y1, width, y2);
                    slice_image(img_data, width, y1, y2).then(function(uri) {
                        slices.push(uri);
                        recur(y2);
                    });
                } else {
                    defer.resolve(slices);
                }
            })(0);
{'fraction_non_alphanumeric': 0.1468824261627249, 'fraction_numerical': 0.007355437365621817, 'mean_word_length': 1.3075718015665796, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '3332526', 'n_tokens_mistral': 2536, 'n_tokens_neox': 2374, 'n_words': 601}