<commit_before>package main

import (
	"code.google.com/p/go-netrc/netrc"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"sort"
)

const (
	VERSION = "0.0.1"
)

// sort interface-typed arrays by first-class functions
type ByFn struct {
	elems []interface{}
	comp  func(a, b interface{}) bool
}

func (c ByFn) Len() int           { return len(c.elems) }
func (c ByFn) Less(i, j int) bool { return c.comp(c.elems[i], c.elems[j]) }
func (c ByFn) Swap(i, j int)      { c.elems[i], c.elems[j] = c.elems[j], c.elems[i] }

func getCreds(machine string) (user, pass string) {
	m, err := netrc.FindMachine(os.Getenv("HOME")+"/.netrc", machine)
	if err != nil {
		panic(err)
	}

	return m.Login, m.Password
}

// generic api requests
func apiReq(meth string, url string) interface{} {
	client := &http.Client{}
	req, err := http.NewRequest(meth, url, nil)
	if err != nil {
		panic(err)
	}

	req.SetBasicAuth(getCreds(req.Host))
	req.Header.Add("User-Agent", fmt.Sprintf("hk/%s", VERSION))
	req.Header.Add("Accept", "application/json")
	res, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	if res.StatusCode == 401 {
		error("Unauthorized")
	}
	if res.StatusCode == 403 {<commit_msg>reuse the default http client<commit_after>package main

import (
	"code.google.com/p/go-netrc/netrc"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"sort"
)

const (
	VERSION = "0.0.1"
)

// sort interface-typed arrays by first-class functions
type ByFn struct {
	elems []interface{}
	comp  func(a, b interface{}) bool
}

func (c ByFn) Len() int           { return len(c.elems) }
func (c ByFn) Less(i, j int) bool { return c.comp(c.elems[i], c.elems[j]) }
func (c ByFn) Swap(i, j int)      { c.elems[i], c.elems[j] = c.elems[j], c.elems[i] }

func getCreds(machine string) (user, pass string) {
	m, err := netrc.FindMachine(os.Getenv("HOME")+"/.netrc", machine)
	if err != nil {
		panic(err)
	}

	return m.Login, m.Password
}

// generic api requests
func apiReq(meth string, url string) interface{} {
	req, err := http.NewRequest(meth, url, nil)
	if err != nil {
		panic(err)
	}

	req.SetBasicAuth(getCreds(req.Host))
	req.Header.Add("User-Agent", fmt.Sprintf("hk/%s", VERSION))
	req.Header.Add("Accept", "application/json")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	if res.StatusCode == 401 {
		error("Unauthorized")
	}
	if res.StatusCode == 403 {
{'fraction_non_alphanumeric': 0.17872161480235493, 'fraction_numerical': 0.007569386038687973, 'mean_word_length': 3.6830708661417324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '540871', 'n_tokens_mistral': 979, 'n_tokens_neox': 954, 'n_words': 228}