<commit_before>package main

import (
    "fmt"
    "net/http"
    "flag"
    "strings"
    "strconv"
    "encoding/base64"
    "github.com/mssola/user_agent"
    "github.com/dchest/uniuri"
)

var Size int

func prefix(r *http.Request) string {
    ua := new(user_agent.UserAgent)
    ua.Parse(r.UserAgent())

    os := ua.OS()
    if strings.Contains(os, "Linux") {
        return "lin"
    } else if strings.Contains(os, "Windows") {
        return "win"
    } else {
        return "srv"
    }
}

func randomName(length int) string {
    return uniuri.NewLen(length)
}

func hashName(id string) string {
//    h := md5.New()
//    h.Write([]byte(id))
//    return base64.URLEncoding.EncodeToString(h.Sum(nil))
    return base64.URLEncoding.EncodeToString([]byte(id))
}

func handler(w http.ResponseWriter, r *http.Request, size int) {
    id := r.FormValue("id")

    tmpsize := r.FormValue("size")

    if len(tmpsize) != 0 {
      s, err := strconv.Atoi(tmpsize)
      size = s
      if err != nil {
        fmt.Println(err)
        return
      }
    }

    prefix := prefix(r)
    var suffix string
    if len(id) != 0 {
      suffix = hashName(id)[0:size-3]
    } else {
      suffix = randomName(size-3)
    }
    name := strings.Join([]string{ prefix, suffix},"")
    fmt.Fprintf(w, "%s", name)
}

func main() {
    port := flag.Int("port", 8080, "Port to use")
    address := flag.String("address", "", "Address to bind")
    size := flag.Int("size", 10, "Default final hostname size")

    flag.Parse()

    socket := fmt.Sprint(*address, ":", *port)
    fmt.Printf("Bind to %s", socket)
    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {<commit_msg>Manage generated base64 < size<commit_after>package main

import (
    "fmt"
    "net/http"
    "flag"
    "strings"
    "strconv"
    "encoding/base64"
    "github.com/mssola/user_agent"
    "github.com/dchest/uniuri"
)

var Size int

func prefix(r *http.Request) string {
    ua := new(user_agent.UserAgent)
    ua.Parse(r.UserAgent())

    os := ua.OS()
    if strings.Contains(os, "Linux") {
        return "lin"
    } else if strings.Contains(os, "Windows") {
        return "win"
    } else {
        return "srv"
    }
}

func randomName(length int) string {
    return uniuri.NewLen(length)
}

func hashName(id string) string {
//    h := md5.New()
//    h.Write([]byte(id))
//    return base64.URLEncoding.EncodeToString(h.Sum(nil))
    return base64.URLEncoding.EncodeToString([]byte(id))
}

func handler(w http.ResponseWriter, r *http.Request, size int) {
    id := r.FormValue("id")

    tmpsize := r.FormValue("size")

    if len(tmpsize) != 0 {
      s, err := strconv.Atoi(tmpsize)
      size = s
      if err != nil {
        fmt.Println(err)
        return
      }
    }

    prefix := prefix(r)
    var suffix string
    if len(id) != 0 {
      ts := hashName(id)
      if len(ts) >= size-3 {
        suffix = ts[0:size-3]
      } else {
        suffix = ts
      }
    } else {
      suffix = randomName(size-3)
    }
    name := strings.Join([]string{ prefix, suffix},"")
    fmt.Fprintf(w, "%s", name)
}

func main() {
    port := flag.Int("port", 8080, "Port to use")
    address := flag.String("address", "", "Address to bind")
    size := flag.Int("size", 10, "Default final hostname size")

    flag.Parse()

    socket := fmt.Sprint(*address, ":", *port)
    fmt.Printf("Bind to %s", socket)
    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
{'fraction_non_alphanumeric': 0.1644585253456221, 'fraction_numerical': 0.011232718894009217, 'mean_word_length': 2.518743667679838, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 4, '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': '1290168', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1231, 'n_words': 273}