<commit_before>// Handlers for HTTP requests to save and load playground examples.
//
// handlerSave() handles a POST request with bundled playground source code.
// The bundle is persisted in a database and a unique ID returned.
// handlerLoad() handles a GET request with an id parameter. It returns the
// bundle saved under the provided ID, if any.
// The current implementation uses a MySQL-like SQL database for persistence.

package main

import (
	crand "crypto/rand"
	"encoding/binary"
	"encoding/hex"
	"encoding/json"
	"flag"
	"fmt"
	"log"
	"net/http"
	"time"

	"v.io/lib/dbutil"

	"playground/lib/lsql"
)

var (
	// Path to SQL configuration file, as described in v.io/lib/dbutil/mysql.go.
	sqlConf = flag.String("sqlconf", "", "Path to SQL configuration file. If empty, load and save requests are disabled. "+dbutil.SqlConfigFileDescription)

	// Testing parameter, use default value for production.
	// Name of dataset to use. Used as table name prefix (a single SQL database
	// can contain multiple datasets).
	dataset = flag.String("dataset", "pg", "Testing: Name of dataset to use (and create if needed, when allowed by setupdb).")

	// If set, will attempt to create any missing database tables for the given
	// dataset. Idempotent.
	setupDB = flag.Bool("setupdb", false, "Whether to create missing database tables for dataset.")<commit_msg>TBR: playground: Fix import path after v.io/lib move.<commit_after>// Handlers for HTTP requests to save and load playground examples.
//
// handlerSave() handles a POST request with bundled playground source code.
// The bundle is persisted in a database and a unique ID returned.
// handlerLoad() handles a GET request with an id parameter. It returns the
// bundle saved under the provided ID, if any.
// The current implementation uses a MySQL-like SQL database for persistence.

package main

import (
	crand "crypto/rand"
	"encoding/binary"
	"encoding/hex"
	"encoding/json"
	"flag"
	"fmt"
	"log"
	"net/http"
	"time"

	"v.io/x/lib/dbutil"

	"playground/lib/lsql"
)

var (
	// Path to SQL configuration file, as described in v.io/x/lib/dbutil/mysql.go.
	sqlConf = flag.String("sqlconf", "", "Path to SQL configuration file. If empty, load and save requests are disabled. "+dbutil.SqlConfigFileDescription)

	// Testing parameter, use default value for production.
	// Name of dataset to use. Used as table name prefix (a single SQL database
	// can contain multiple datasets).
	dataset = flag.String("dataset", "pg", "Testing: Name of dataset to use (and create if needed, when allowed by setupdb).")

	// If set, will attempt to create any missing database tables for the given
	// dataset. Idempotent.
	setupDB = flag.Bool("setupdb", false, "Whether to create missing database tables for dataset.")
{'fraction_non_alphanumeric': 0.10166425470332852, 'fraction_numerical': 0.0, 'mean_word_length': 3.8423817863397547, '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': '3297147', 'n_tokens_mistral': 804, 'n_tokens_neox': 780, 'n_words': 350}