<commit_before>/*globals $,console,d3,cookieJar */

/*!
 * github.js
 *
 * Copyright 2016 <NAME>; Licensed MIT
 */

 /*
GitHub API Reference: https://api.github.com
    [ ] "current_user_url": "https://api.github.com/user",
    [-] "current_user_authorizations_html_url": "https://github.com/settings/connections/applications{/client_id}",
    [-] "authorizations_url": "https://api.github.com/authorizations",
    [-] "code_search_url": "https://api.github.com/search/code?q={query}{&page,per_page,sort,order}",
    [-] "emails_url": "https://api.github.com/user/emails",
    [ ] "emojis_url": "https://api.github.com/emojis",
    [-] "events_url": "https://api.github.com/events",
    [-] "feeds_url": "https://api.github.com/feeds",
    [ ] "followers_url": "https://api.github.com/user/followers",
    [ ] "following_url": "https://api.github.com/user/following{/target}",
    [ ] "gists_url": "https://api.github.com/gists{/gist_id}",
    [-] "hub_url": "https://api.github.com/hub",
    [-] "issue_search_url": "https://api.github.com/search/issues?q={query}{&page,per_page,sort,order}",
    [?] "issues_url": "https://api.github.com/issues",
    [-] "keys_url": "https://api.github.com/user/keys",
    [-] "notifications_url": "https://api.github.com/notifications",
    [?] "organization_repositories_url": "https://api.github.com/orgs/{org}/repos{?type,page,per_page,sort}",
    [?] "organization_url": "https://api.github.com/orgs/{org}",
    [-] "public_gists_url": "https://api.github.com/gists/public",
    [x] "rate_limit_url": "https://api.github.com/rate_limit",
    [x] "repository_url": "https://api.github.com/repos/{owner}/{repo}",
    [-] "repository_search_url": "https://api.github.com/search/repositories?q={query}{&page,per_page,sort,order}",
    [ ] "current_user_repositories_url": "https://api.github.com/user/repos{?type,page,per_page,sort}",
    [ ] "starred_url": "https://api.github.com/user/starred{/owner}{/repo}",
    [ ] "starred_gists_url": "https://api.github.com/gists/starred",
    [?] "team_url": "https://api.github.com/teams",
    [x] "user_url": "https://api.github.com/users/{user}",
    [-] "user_organizations_url": "https://api.github.com/user/orgs",
    [ ] "user_repositories_url": "https://api.github.com/users/{user}/repos{?type,page,per_page,sort}",
    [-] "user_search_url": "https://api.github.com/search/users?q={query}{&page,per_page,sort,order}"
*/

/*
Github API to use:
    - [ ] "current_user_url": "https://api.github.com/user"
    - [ ] "current_user_repositories_url": "https://api.github.com/user/repos{?type,page,per_page,sort}"
    - [x] "user_url": "https://api.github.com/users/{user}"
    - [ ] "user_repositories_url": "https://api.github.com/users/{user}/repos{?type,page,per_page,sort}"
    - [ ] "emojis_url": "https://api.github.com/emojis"
    - [ ] "followers_url": "https://api.github.com/users/{user}/followers"
    - [ ] "following_url": "https://api.github.com/users/{user}/following"
    - [ ] "gists_url": "https://api.github.com/users/{user}/gists"
    - [x] "rate_limit_url": "https://api.github.com/rate_limit"
    - [x] "repository_url": "https://api.github.com/repos/{owner}/{repo}"
    - [ ] "starred_url": "https://api.github.com/user/starred"
    - [ ] "starred_gists_url": "https://api.github.com/gists/starred"

    * on all append: '?=access_token{access_token}'
*/

github = {
    current_user_url : function () {
        // https://api.github.com/user"
    }<commit_msg>build function to parse http request headers<commit_after>/*globals $,console,d3,cookieJar */

/*!
 * github.js
 *
 * Copyright 2016 <NAME>; Licensed MIT
 */

 /*
GitHub API Reference: https://api.github.com
    [ ] "current_user_url": "https://api.github.com/user",
    [-] "current_user_authorizations_html_url": "https://github.com/settings/connections/applications{/client_id}",
    [-] "authorizations_url": "https://api.github.com/authorizations",
    [-] "code_search_url": "https://api.github.com/search/code?q={query}{&page,per_page,sort,order}",
    [-] "emails_url": "https://api.github.com/user/emails",
    [ ] "emojis_url": "https://api.github.com/emojis",
    [-] "events_url": "https://api.github.com/events",
    [-] "feeds_url": "https://api.github.com/feeds",
    [ ] "followers_url": "https://api.github.com/user/followers",
    [ ] "following_url": "https://api.github.com/user/following{/target}",
    [ ] "gists_url": "https://api.github.com/gists{/gist_id}",
    [-] "hub_url": "https://api.github.com/hub",
    [-] "issue_search_url": "https://api.github.com/search/issues?q={query}{&page,per_page,sort,order}",
    [?] "issues_url": "https://api.github.com/issues",
    [-] "keys_url": "https://api.github.com/user/keys",
    [-] "notifications_url": "https://api.github.com/notifications",
    [?] "organization_repositories_url": "https://api.github.com/orgs/{org}/repos{?type,page,per_page,sort}",
    [?] "organization_url": "https://api.github.com/orgs/{org}",
    [-] "public_gists_url": "https://api.github.com/gists/public",
    [x] "rate_limit_url": "https://api.github.com/rate_limit",
    [x] "repository_url": "https://api.github.com/repos/{owner}/{repo}",
    [-] "repository_search_url": "https://api.github.com/search/repositories?q={query}{&page,per_page,sort,order}",
    [ ] "current_user_repositories_url": "https://api.github.com/user/repos{?type,page,per_page,sort}",
    [ ] "starred_url": "https://api.github.com/user/starred{/owner}{/repo}",
    [ ] "starred_gists_url": "https://api.github.com/gists/starred",
    [?] "team_url": "https://api.github.com/teams",
    [x] "user_url": "https://api.github.com/users/{user}",
    [-] "user_organizations_url": "https://api.github.com/user/orgs",
    [ ] "user_repositories_url": "https://api.github.com/users/{user}/repos{?type,page,per_page,sort}",
    [-] "user_search_url": "https://api.github.com/search/users?q={query}{&page,per_page,sort,order}"
*/

/*
Github API to use:
    - [ ] "current_user_url": "https://api.github.com/user"
    - [ ] "current_user_repositories_url": "https://api.github.com/user/repos{?type,page,per_page,sort}"
    - [x] "user_url": "https://api.github.com/users/{user}"
    - [ ] "user_repositories_url": "https://api.github.com/users/{user}/repos{?type,page,per_page,sort}"
    - [ ] "emojis_url": "https://api.github.com/emojis"
    - [ ] "followers_url": "https://api.github.com/users/{user}/followers"
    - [ ] "following_url": "https://api.github.com/users/{user}/following"
    - [ ] "gists_url": "https://api.github.com/users/{user}/gists"
    - [x] "rate_limit_url": "https://api.github.com/rate_limit"
    - [x] "repository_url": "https://api.github.com/repos/{owner}/{repo}"
    - [ ] "starred_url": "https://api.github.com/user/starred"
    - [ ] "starred_gists_url": "https://api.github.com/gists/starred"

    * on all append: '?=access_token{access_token}'
*/


function parseHeaders(header_string) {
    /* Parses a header string as returned by xhr.getAllResponseHeaders()
    Example Header:
        X-OAuth-Scopes:
        X-RateLimit-Remaining: 4878
        X-Accepted-OAuth-Scopes:
        Last-Modified: Sat, 24 Oct 2015 21:02:27 GMT
        ETag: W/"bc440d9ad7a60bc67bbf7f3513528724"
        Content-Type: application/json; charset=utf-8
        Cache-Control: private, max-age=60, s-maxage=60
        X-RateLimit-Reset: 1455024495
        X-RateLimit-Limit: 5000
    */
    var lines = header_string.trim().split('\n');
        headers = {},
        line = '',
        key = '',
        val = '',
        number = null;

    for (line in lines) {
        // split line on first `:` for key:val par
        keyval = lines[line].split(/:(.*)/);
        key = keyval[0].trim();
        val = keyval[1].trim();
        // try to parse value as null
        if (val === "") {
            val = null;
        } else {
            // try to parse as number
            number = parseInt(val);
            if (!isNaN(number)) {
                val = number;
            } else {
                // try to parse as number
                date = new Date(val);
                if (!isNaN(date.getTime())) {
                    val = date;
                }
                // leave as string
            }
        }
        // Place in object
        headers[key] = val;
    }

    return headers;
}


github = {
    current_user_url : function () {
        // https://api.github.com/user"
    }
{'fraction_non_alphanumeric': 0.21477867682056165, 'fraction_numerical': 0.00797239409804855, 'mean_word_length': 3.204602301150575, 'pattern_counts': {'":': 84, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 88, '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': '3190218', 'n_tokens_mistral': 3112, 'n_tokens_neox': 3005, 'n_words': 341}