<commit_before><commit_msg>Add convenience utility to base64 local images<commit_after>#!/usr/local/bin/node
// node ./base64 ./bg-temp.png
//

const fs = require('fs')
,path = require('path')


let filePath = process.argv[2]
if (!filePath) {
	throw new Error('Missing image file path')
}
filePath = path.join(__dirname, filePath)


fs.readFile(filePath, (err,data) => {
	const prefix = 'data:image/'+getContentTypeFromFilename(filePath)+';base64,'
	if (err) {
		if (err.code == 'ENOENT') {
			throw new Error('Missing file: ' + filePath)
		}
		throw new Error('Error fetching file: ' + filePath)
		return done()
	}
	const output = prefix+data.toString('base64')
	console.log(output)
})


function getContentTypeFromFilename(fn)  {
	var ext = fn.split('.').pop().toLowerCase()
	if (ext == 'jpg') {
		ext = 'jpeg'
	}
	return ext
}

{'fraction_non_alphanumeric': 0.1686746987951807, 'fraction_numerical': 0.010843373493975903, 'mean_word_length': 4.396103896103896, 'pattern_counts': {'":': 0, '<': 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': '2784482', 'n_tokens_mistral': 305, 'n_tokens_neox': 290, 'n_words': 68}