fix quote lengths

This commit is contained in:
Miodec 2022-05-28 17:14:55 +02:00
parent e1674524dc
commit b0343adfde
6 changed files with 49 additions and 15 deletions

View file

@ -0,0 +1,34 @@
const fs = require("fs");
const V = require("jsonschema").Validator;
const JSONValidator = new V();
function escapeRegExp(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function fixQuoteLengths() {
return new Promise((resolve, reject) => {
const quotesFiles = fs.readdirSync("../static/quotes/");
quotesFiles.forEach((quotefilename) => {
quotefilename = quotefilename.split(".")[0];
let quoteData = JSON.parse(
fs.readFileSync(`../static/quotes/${quotefilename}.json`, {
encoding: "utf8",
flag: "r",
})
);
quoteData.quotes.forEach((quote) => {
quote.length = quote.text.length;
});
fs.writeFileSync(
`../static/quotes/${quotefilename}.json`,
JSON.stringify(quoteData, null, 2)
);
});
resolve();
});
}
fixQuoteLengths();

View file

@ -53,7 +53,7 @@
"text": "If you have to ask, you will never know. If you know, you need only ask.",
"source": "Harry Potter and the Deathly Hallows",
"id": 8,
"length": 70
"length": 72
},
{
"text": "Your memory is the glue that binds your life together.",
@ -29711,7 +29711,7 @@
"text": "I solemnly swear that I am up to no good.",
"source": "Harry Potter and the Prisoner of Azkaban",
"id": 5024,
"length": 36
"length": 41
},
{
"text": "Honestly, am I the only person who's ever bothered to read 'Hogwarts: A History?'",
@ -31660,7 +31660,7 @@
{
"text": "Dear Mario: Please come to the castle. I've baked a cake for you. Yours Truly- Princess Toadstool Peach.",
"source": "Super Mario 64",
"length": 105,
"length": 104,
"id": 5362
},
{
@ -32620,7 +32620,7 @@
{
"text": "I have little sympathy with the rather prevalent concept that man is basically irrational, and that his impulses, if not controlled, will lead to destruction of others and self. Man's behavior is exquisitely rational, moving with subtle and ordered complexity toward the goals his organism is endeavoring to achieve. The tragedy for most of us is that our defenses keep us from being aware of this rationality, so that consciously we are moving in one direction, while organismically we are moving in another.",
"source": "Carl Rogers, On Becoming a Person",
"length": 508,
"length": 509,
"id": 5532
},
{
@ -33532,7 +33532,7 @@
{
"text": "Let's build a happy little cloud. Let's build some happy little trees.",
"source": "Bob Ross",
"length": 68,
"length": 70,
"id": 5698
},
{
@ -34132,7 +34132,7 @@
{
"text": "\"There are many types of monsters in this world, monsters who will not show themselves and who cause trouble. Monsters who abduct children, monsters who devour dreams, monsters who suck blood, and monsters who always tell lies. Lying monsters are a real nuisance. They are much more cunning than other monsters. They pose as humans, even though they have no understanding of the human heart. They eat, even though they've never experienced hunger. They study even though they have no interest in academics. They seek friendship even though they do not know how to love. If I were to encounter such a monster, I would likely be eaten by it because, in truth, I am that monster.\"",
"source": "Death Note",
"length": 678,
"length": 677,
"id": 5798
},
{
@ -34150,7 +34150,7 @@
{
"text": "It may be hard right now but you must silence those thoughts. Stop counting those things you have lost, what is gone is gone. So ask yourself, what is there that still remains to you.",
"source": "one piece",
"length": 182,
"length": 183,
"id": 5801
},
{
@ -34558,7 +34558,7 @@
{
"text": "We all deserve love, even on the days when we aren't our best. 'Cause we all suck, but love can make us suck less. We all deserve love, it's the very best part of being alive. And I would know I just turned 25",
"source": "Lower Your Expectations - Bo Burnham",
"length": 206,
"length": 209,
"id": 5870
},
{

View file

@ -16,7 +16,7 @@
{
"text": "Tama na 'yan inuman na hoy pare ko'y tumagay ka nananabik na lalamunan naghihintay nag-aabang.",
"source": "Inuman Na, Parokya Ni Edgar",
"length": 93,
"length": 94,
"id": 2
},
{

View file

@ -3052,7 +3052,7 @@
{
"text": "Ich danke dir für die anerkennenden Worte über die Dichter und die Dichtkunst. Und für die Belehrung in Sachen Bogenschießen. Eine gute Waffe ist das, der Bogen. Wisst ihr was? Ich glaube, dass sich die Kriegskunst genau in diese Richtung entwickeln wird. In den künftigen Kriegen wird man auf Distanz kämpfen. Man wird eine Waffe mit so großer Reichweite erfinden, dass die Gegner einander umbringen können, ohne sich auch nur zu sehen.",
"source": "Geralt-Saga - Feuertaufe",
"length": 436,
"length": 437,
"id": 513
},
{

View file

@ -1793,7 +1793,7 @@
"id": 298,
"source": "Чалдини Роберт - Психология влияния",
"text": "Информация и знание - не одно и то же. Чтобы информация стала знанием, её надо сначала обработать: получить, отсортировать, проанализировать, интегрировать и сохранить.",
"length": 167
"length": 168
},
{
"id": 299,
@ -2687,7 +2687,7 @@
"id": 447,
"source": "Исигуро Кадзуо - Когда мы были сиротами",
"text": "- И мы, кому выпало на долю бороться со злом, мы. как бы это лучше выразиться? Мы - шнур, который скрепляет планки деревянных жалюзи. Если мы окажемся недостаточно прочными, всё рассыплется.",
"length": 191
"length": 190
},
{
"id": 448,
@ -3263,7 +3263,7 @@
"id": 543,
"source": "Коу Джонатан - Невероятная частная жизнь Максвелла Сима",
"text": "Ни он, ни я никогда не повышали голоса. Если один не соглашался с доводами другого или обижался, мы просто сердито умолкали - и молчали так, бывало, по нескольку лет. В конце концов всё улаживалось, хотя со стороны такой способ решать проблемы кажется по меньшей мере причудливым.",
"length": 279
"length": 280
},
{
"id": 544,
@ -5603,7 +5603,7 @@
"id": 933,
"source": "Хофштадтер Дуглас - Гёдель, Эшер, Бах: Эта бесконечная гирлянда",
"text": "Поскольку наши мозги являются физическими телами, они действуют без инструкций.",
"length": 81
"length": 79
},
{
"id": 934,

View file

@ -148,7 +148,7 @@
{
"text": "He fallado más de 9000 tiros en mi carrera. He perdido casi 300 partidos. En 26 ocasiones, pude hacer la canasta que ganara el partido y fallé. He fracasado una y otra vez en mi vida. Y por esa razón he triunfado.",
"source": "Michael Jordan",
"length": 217,
"length": 213,
"id": 24
},
{