terrain's notebooks

  • 156 - /terrain/156
    Last edited 2 years ago - from: https://npm.runkit.com/
    1+2+3+4+5+"6"
  • random toki pona name - /terrain/random-toki-pona-name
    Last edited 2 years ago
    const vowels = "aeiou".split(""); const consonants = "jptkmnslw".split(""); const illegalSyllables = ["wu", "wo", "ji", "ti"].flatMap(s => [s, s + "n"]); const vowelStartSyllables = vowels.flatMap(v => [v, v + "n"]); const middleSyllables = vowelStartSyllables.flatMap(s => consonants.map(c => c + s)).filter(s => !illegalSyllables.includes(s)); const afterNasalSyllables = middleSyllables.filter(s => !"nm".includes(s[0])); const allSyllables = vowelStartSyllables.concat(middleSyllables); let lastWasNasal = false; function randomSyllable(choice) { const result = choice[Math.floor(Math.random() * choice.length)]; lastWasNasal = result.endsWith("n"); return result; } const totalSyllables = Math.floor(Math.random() * 5) + 3; // <--- length, change this if you want const firstSyllable = randomSyllable(allSyllables) const remainingSyllables = Array(totalSyllables - 1).fill(0).map(_ => randomSyllable(lastWasNasal ? afterNasalSyllables : middleSyllables)); firstSyllable + remainingSyllables.join("")
  • abuse - /terrain/abuse
    Last edited 4 years ago
    function main() { var theNaN = "NaN" var undefined = eval(theNaN); var NaN = 4 / 0; console.log(NaN); // Infinity var NaN = undefined; console.log(NaN); // undefined var NaN = Number.NaN; var undefined = eval(theNaN); console.log(undefined); // NaN } main();
  • AltStore - /terrain/altstore
    Last edited 4 years ago
    require("array-flat-polyfill"); const fetch = require("node-fetch"); const app = require("express")(); app.get("/", async (req, res) => { try { const alpha = await fetch("https://alpha.altstore.io").then(res => res.json()); const repo = await fetch("https://apps.altstore.io").then(res => res.json()); repo.apps = [ repo.apps.map(app => { if (app.beta) { app.beta = false; app.name += " (Beta)"; } return app; }), alpha.apps.filter( app => !app.name.endsWith("(Stable)") ) ].flat().sort((a, b) => a.name.localeCompare(b.name)); repo.news = [ repo.news, alpha.news ].flat(); repo.name = "AltStore (Stable + Alpha + Beta)"; res.json(repo); } catch (e) { console.error(e); res.status(500).json({ name: "Error!", identifier: "error" }); } }); app.listen(3000);