<commit_before>package grid

import (
	"crypto/md5"
	"fmt"
	"github.com/taironas/tinygraphs/colors"
	"github.com/taironas/tinygraphs/draw"
	"github.com/taironas/tinygraphs/misc"
	"github.com/taironas/tinygraphs/write"
	"image"
	"io"
	"log"
	"net/http"
)

// gridColorHandler is the handler for /grid/square/[0-9]+/?
// build a 6x6 grid with alternate colors based on the number passed in the url
func Square(w http.ResponseWriter, r *http.Request) {
	id, err := misc.PermalinkString(r, 3)
	if err != nil {
		log.Printf("error when extracting permalink id: %v", err)
	} else {
		m := image.NewRGBA(image.Rect(0, 0, 240, 240))
		colorMap := colors.MapOfColorPatterns()
		h := md5.New()
		io.WriteString(h, id)
		log.Printf("md5: %x", h.Sum(nil))
		key := fmt.Sprintf("%x", h.Sum(nil)[:])
		draw.Square(m, key, colorMap[0][0], colorMap[0][1])
		var img image.Image = m
		write.Image(w, &img)
	}
}

// gridColorHandler is the handler for /grid/square/[0-8]/[a-zA-Z0-9]+/?
// build a 6x6 grid with alternate colors based on the number passed in the url
func SquareColor(w http.ResponseWriter, r *http.Request) {

	if colorId, err := misc.PermalinkID(r, 3); err != nil {
		log.Printf("error when extracting permalink id: %v", err)
	} else {
		if id, err1 := misc.PermalinkString(r, 4); err1 == nil {
			m := image.NewRGBA(image.Rect(0, 0, 240, 240))
			colorMap := colors.MapOfColorPatterns()
			h := md5.New()
			io.WriteString(h, id)
			log.Printf("md5: %x", h.Sum(nil))
			key := fmt.Sprintf("%x", h.Sum(nil)[:])
			draw.Square(m, key, colorMap[int(colorId)][0], colorMap[int(colorId)][1])
			var img image.Image = m
			write.Image(w, &img)
		} else {
			log.Printf("error when extracting permalink string: %v", err)
		}
	}
}<commit_msg>remove unnecessary logs<commit_after>package grid

import (
	"crypto/md5"
	"fmt"
	"github.com/taironas/tinygraphs/colors"
	"github.com/taironas/tinygraphs/draw"
	"github.com/taironas/tinygraphs/misc"
	"github.com/taironas/tinygraphs/write"
	"image"
	"io"
	"log"
	"net/http"
)

// gridColorHandler is the handler for /grid/square/[0-9]+/?
// build a 6x6 grid with alternate colors based on the number passed in the url
func Square(w http.ResponseWriter, r *http.Request) {
	id, err := misc.PermalinkString(r, 3)
	if err != nil {
		log.Printf("error when extracting permalink id: %v", err)
	} else {
		m := image.NewRGBA(image.Rect(0, 0, 240, 240))
		colorMap := colors.MapOfColorPatterns()
		h := md5.New()
		io.WriteString(h, id)
		key := fmt.Sprintf("%x", h.Sum(nil)[:])
		draw.Square(m, key, colorMap[0][0], colorMap[0][1])
		var img image.Image = m
		write.Image(w, &img)
	}
}

// gridColorHandler is the handler for /grid/square/[0-8]/[a-zA-Z0-9]+/?
// build a 6x6 grid with alternate colors based on the number passed in the url
func SquareColor(w http.ResponseWriter, r *http.Request) {

	if colorId, err := misc.PermalinkID(r, 3); err != nil {
		log.Printf("error when extracting permalink id: %v", err)
	} else {
		if id, err1 := misc.PermalinkString(r, 4); err1 == nil {
			m := image.NewRGBA(image.Rect(0, 0, 240, 240))
			colorMap := colors.MapOfColorPatterns()
			h := md5.New()
			io.WriteString(h, id)
			key := fmt.Sprintf("%x", h.Sum(nil)[:])
			draw.Square(m, key, colorMap[int(colorId)][0], colorMap[int(colorId)][1])
			var img image.Image = m
			write.Image(w, &img)
		} else {
			log.Printf("error when extracting permalink string: %v", err)
		}
	}
}
{'fraction_non_alphanumeric': 0.17209985315712187, 'fraction_numerical': 0.02408223201174743, 'mean_word_length': 3.8936781609195403, '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': '486183', 'n_tokens_mistral': 1460, 'n_tokens_neox': 1321, 'n_words': 324}