Skip to content

Instantly share code, notes, and snippets.

@ginsm
ginsm / .gitattributes
Last active September 11, 2025 09:51
Windows Terminal Background Changer (Python)
# Makes the change_background script have python syntax highlighting
change_background linguist-language=python
@ginsm
ginsm / splitIntoPages.js
Last active September 10, 2021 10:49
Splits a string into Minecraft pages (roughly)
function splitIntoPages(str, { maxLineWidth = 114, maxLines = 14, doubleNewLine = false, indentParagraph = true } = {}) {
// Replace any literary punctuations & newlines in the string
str = str
.replace(/“/g, '"')
.replace(/”/g, '"')
.replace(/’/g, "'")
.replace(/…/g, '...');
// Contains widths for the majority of valid characters
const characterWidths = JSON.parse("{\"0\":\"6\",\"1\":\"6\",\"2\":\"6\",\"3\":\"6\",\"4\":\"6\",\"5\":\"6\",\"6\":\"6\",\"7\":\"6\",\"8\":\"6\",\"9\":\"6\",\" \":\"4\",\"!\":\"2\",\"\\\"\":\"5\",\"#\":\"6\",\"$\":\"6\",\"%\":\"6\",\"&\":\"6\",\"'\":\"3\",\"(\":\"5\",\")\":\"5\",\"*\":\"5\",\"+\":\"6\",\",\":\"2\",\"-\":\"6\",\".\":\"2\",\"/\":\"6\",\":\":\"2\",\";\":\"2\",\"<\":\"5\",\">\":\"5\",\"?\":\"6\",\"@\":\"7\",\"A\":\"6\",\"B\":\"6\",\"C\":\"6\",\"D\":\"6\",\"E\":\"6\",\"F\":\"6\",\"G\":\"6\",\"H\":\"6\",\"I\":\"4\",\"J\":\"6\",\"K\":\"6\",\"L\":\"6\",\"M\":\"6\",\"N\":\"6\",\"O\":\"6\",\"P\":\"6\",\"Q\":\"6\",\"R\":\"6\",\"S\":\"6\",\"T\":\"6\",\"