<commit_before>package main

import (
	"flag"
	"fmt"
	"net/http"
	"strings"

	"github.com/avelino/vim-bootstrap/generate"
	"github.com/avelino/vim-bootstrap/web"
	"github.com/gorilla/mux"
	"github.com/urfave/negroni"
)

func main() {
	langs := flag.String("langs", "", "Set languages used: go,python,c")
	editor := flag.String("editor", "vim", "Set editor: vim or nvim")
	server := flag.Bool("server", false, "Up http server")
	flag.Parse()

	if *server {
		n := negroni.Classic()
		r := mux.NewRouter()
		r.HandleFunc("/", web.HandleHome).Methods("GET")
		r.HandleFunc("/generate.vim", web.HandleGenerate).Methods("POST")
		r.HandleFunc("/langs", web.HandleLangs)
		r.HandleFunc("/hook", web.HandleHook).Methods("POST")
		r.PathPrefix("/assets").Handler(
			http.StripPrefix("/assets", http.FileServer(http.Dir("./template/assets/"))))

		n.UseHandler(r)
		n.Run(":3000")
	}

	obj := generate.Object{
		Language: strings.Split(*langs, ","),
		Editor:   *editor,
		Version:  web.HashCommit(),
	}
	gen := generate.Generate(&obj)
	fmt.Println(gen)
}<commit_msg>dynamic http server port 2019-03-16T14:53:59.193936+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch<commit_after>package main

import (
	"flag"
	"fmt"
	"net/http"
	"os"
	"strings"

	"github.com/avelino/vim-bootstrap/generate"
	"github.com/avelino/vim-bootstrap/web"
	"github.com/gorilla/mux"
	"github.com/urfave/negroni"
)

func main() {
	langs := flag.String("langs", "", "Set languages used: go,python,c")
	editor := flag.String("editor", "vim", "Set editor: vim or nvim")
	server := flag.Bool("server", false, "Up http server")
	flag.Parse()
	port := os.Getenv("PORT")
	if port == "" {
		port = "3000"
	}

	if *server {
		n := negroni.Classic()
		r := mux.NewRouter()
		r.HandleFunc("/", web.HandleHome).Methods("GET")
		r.HandleFunc("/generate.vim", web.HandleGenerate).Methods("POST")
		r.HandleFunc("/langs", web.HandleLangs)
		r.HandleFunc("/hook", web.HandleHook).Methods("POST")
		r.PathPrefix("/assets").Handler(
			http.StripPrefix("/assets", http.FileServer(http.Dir("./template/assets/"))))

		n.UseHandler(r)
		n.Run(fmt.Sprintf(":%s", port))
	}

	obj := generate.Object{
		Language: strings.Split(*langs, ","),
		Editor:   *editor,
		Version:  web.HashCommit(),
	}
	gen := generate.Generate(&obj)
	fmt.Println(gen)
}
{'fraction_non_alphanumeric': 0.2, 'fraction_numerical': 0.015711252653927813, 'mean_word_length': 4.47906976744186, 'pattern_counts': {'":': 2, '<': 3, '<?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': '5666503', 'n_tokens_mistral': 940, 'n_tokens_neox': 874, 'n_words': 157}