<commit_before>package ext

import (
	"crypto/rand"
	"fmt"
	"io"
	"math"
	"math/big"
)

var (
	maxBigInt = big.NewInt(math.MaxInt64)
)

func RandomBigInt() *big.Int {
	n, err := rand.Int(rand.Reader, maxBigInt)
	ANoError(err)
	return n
}

func RandomUint64() uint64 {
	return RandomBigInt().Uint64()
}

func RandomInt64() int64 {
	return RandomBigInt().Int64()
}

// newUUID generates a random UUID according to RFC 4122
func NewUUID() string {
	uuid := make([]byte, 16)
	n, err := io.ReadFull(rand.Reader, uuid)
	ATrue(n == len(uuid) && err == nil)
	// variant bits; see section 4.1.1
	uuid[8] = uuid[8]&^0xc0 | 0x80
	// version 4 (pseudo-random); see section 4.1.3
	uuid[6] = uuid[6]&^0xf0 | 0x40
	return fmt.Sprintf("%x-%x-%x-%x-%x", uuid[0:4], uuid[4:6], uuid[6:8], uuid[8:10], uuid[10:])
}<commit_msg>RandomUint16; DeviceID<commit_after>package ext

import (
	"crypto/rand"
	"crypto/sha1"
	"encoding/hex"
	"fmt"
	"io"
	"math"
	"math/big"
	"os"
)

var (
	maxBigInt = big.NewInt(math.MaxInt64)
)

func RandomBigInt() *big.Int {
	n, err := rand.Int(rand.Reader, maxBigInt)
	ANoError(err)
	return n
}

func RandomUint16() uint16 {
	return uint16(RandomBigInt().Uint64())
}

func RandomUint64() uint64 {
	return RandomBigInt().Uint64()
}

func RandomInt64() int64 {
	return RandomBigInt().Int64()
}

// newUUID generates a random UUID according to RFC 4122
func NewUUID() string {
	uuid := make([]byte, 16)
	n, err := io.ReadFull(rand.Reader, uuid)
	ATrue(n == len(uuid) && err == nil)
	// variant bits; see section 4.1.1
	uuid[8] = uuid[8]&^0xc0 | 0x80
	// version 4 (pseudo-random); see section 4.1.3
	uuid[6] = uuid[6]&^0xf0 | 0x40
	return fmt.Sprintf("%x-%x-%x-%x-%x", uuid[0:4], uuid[4:6], uuid[6:8], uuid[8:10], uuid[10:])
}

func DeviceID() string {
	hostname, err := os.Hostname()
	ANoError(err)
	hasher := sha1.New()
	hasher.Write([]byte(hostname))
	return hex.EncodeToString(hasher.Sum(nil))
}
{'fraction_non_alphanumeric': 0.186022070415134, 'fraction_numerical': 0.06095638465580662, 'mean_word_length': 4.333333333333333, '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': '2899812', 'n_tokens_mistral': 847, 'n_tokens_neox': 816, 'n_words': 177}