<commit_before>package main

import (
	"fmt"
	"github.com/dchest/uniuri"
	"io"
	"io/ioutil"
	"net/http"
	"os"
)

const (
	directory = "/tmp/"
	address   = "http://localhost:8080/p/"
	length    = 4
	text      = "$ <command> | curl -F 'paste=<-'" + address + "\n"
)

func check(e error) {
	if e != nil {
		panic(e)
	}
}

func exists(location string) bool {
	if _, err := os.Stat(location); err != nil {
		if os.IsNotExist(err) {
			return false
		}
	}
	return true

}

func generateName() string {
	s := uniuri.NewLen(length)
	file := exists(directory + s)
	if file == true {
		generateName()
	}

	return s

}
func save(buf []byte) string {
	paste := buf[92 : len(buf)-46]

	s := generateName()
	location := directory + s

	err := ioutil.WriteFile(location, paste, 0644)
	check(err)

	return s
}

func pasteHandler(w http.ResponseWriter, r *http.Request) {
	switch r.Method {
	case "GET":
		fmt.Fprintf(w, text)
	case "POST":
		buf, _ := ioutil.ReadAll(r.Body)
		io.WriteString(w, address+save(buf)+"\n")

	case "DELETE":
		// Remove the record.
	}
}

func main() {
	http.HandleFunc("/", pasteHandler)
	http.Handle("/p/", http.StripPrefix("/p/", http.FileServer(http.Dir(directory))))

	http.ListenAndServe(":8080", nil)

}<commit_msg>Remove fmt<commit_after>package main

import (
	"github.com/dchest/uniuri"
	"io"
	"io/ioutil"
	"net/http"
	"os"
)

const (
	directory = "/tmp/"
	address   = "http://localhost:8080/p/"
	length    = 4
	text      = "$ <command> | curl -F 'paste=<-'" + address + "\n"
)

func check(e error) {
	if e != nil {
		panic(e)
	}
}

func exists(location string) bool {
	if _, err := os.Stat(location); err != nil {
		if os.IsNotExist(err) {
			return false
		}
	}
	return true

}

func generateName() string {
	s := uniuri.NewLen(length)
	file := exists(directory + s)
	if file == true {
		generateName()
	}

	return s

}
func save(buf []byte) string {
	paste := buf[92 : len(buf)-46]

	s := generateName()
	location := directory + s

	err := ioutil.WriteFile(location, paste, 0644)
	check(err)

	return s
}

func pasteHandler(w http.ResponseWriter, r *http.Request) {
	switch r.Method {
	case "GET":
		io.WriteString(w, text)
	case "POST":
		buf, _ := ioutil.ReadAll(r.Body)
		io.WriteString(w, address+save(buf)+"\n")
	case "DELETE":
		// Remove the record.
	}
}

func main() {
	http.HandleFunc("/", pasteHandler)
	http.Handle("/p/", http.StripPrefix("/p/", http.FileServer(http.Dir(directory))))

	http.ListenAndServe(":8080", nil)

}
{'fraction_non_alphanumeric': 0.17982099267697316, 'fraction_numerical': 0.013832384052074858, 'mean_word_length': 3.414721723518851, 'pattern_counts': {'":': 8, '<': 7, '<?xml version=': 0, '>': 5, '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': '384353', 'n_tokens_mistral': 1030, 'n_tokens_neox': 967, 'n_words': 218}