Skip to content

Instantly share code, notes, and snippets.

@Qix-
Created September 18, 2014 22:47
Show Gist options
  • Save Qix-/cc90789f0bd31473cd31 to your computer and use it in GitHub Desktop.
Save Qix-/cc90789f0bd31473cd31 to your computer and use it in GitHub Desktop.
Portal Fish Recipe Console
'use strict';
var injectables = [
"ingredients",
"for the cake",
"1 2/3 cups all-purpose flour",
"1 1/2 cups granulated sugar",
"2/3 cup unsweetened cocoa powder",
"1 1/2 teaspoons baking soda",
"1 teaspoon salt",
"1 1/2 cups buttermilk",
"1/2 cup vegetable shortening ",
"2 large eggs",
"1 teaspoon vanilla extract",
"1/2 cup Kirsch (cherry liqueur)",
"2 cans sour cherries",
"3 cups heavy whipping cream",
"3/4 cup confectioners' sugar",
"3 tablespoons cocoa",
"for the garnish",
"1 semisweet chocolate bar, frozen",
"8 maraschino cherries",
"one white candle",
"preheat oven to 350 degrees",
"two 8 inch cakepans",
"16 ouches of vanilla frosting",
"fish-shaped candies",
"fish-shaped ethyl benzeneot",
"sediment-shaped sediment",
"fish-shaped volitile organic compounds",
"Don't forget garnishes such as",
"fish-shaped crackers",
"1 can prepared coconut pecan frosting",
"fish-shaped nitrate explosives",
"1 can prepared lies",
"not a lie",
"Glad",
"GladOS",
"[Subject Hometown Here]",
"[Subject Name Here]",
"ATLAS",
"for science",
"test subject",
"chell",
"all your daughters",
"fish-shaped chicken",
"mesa",
"black mesa",
"#1498",
"enrichment center protocols are not designed for fish-shaped test subjects"
];
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789!@#$%^&*()_+-={}|[]\\:\";'<>?,./"
+ "\n\n\n\n";
var degradeChars = "}{,,,::..;!@#$^&*_+<>,./\\][ XQ()))\n";
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
function generateRandomChar(bank, chance) {
var rand = getRandomInt(0, bank.length * chance);
if (rand >= bank.length) {
return '';
} else {
return bank[rand];
}
}
function degradeString(str) {
var newStr = '';
var useBank = degradeChars;
if (str.length > 15) {
useBank += "\n\n\n\n";
}
for (var i = 0, len = str.length; i < len; i++) {
var chr = generateRandomChar(useBank, 50);
newStr += str[i] + chr;
if (Math.random() >= 0.961) {
i += getRandomInt(2, 5);
}
if (Math.random() >= 0.9) {
newStr += generateRandomChar(degradeChars, 1);
}
}
if (Math.random() >= 0.95) {
newStr = newStr.replace(/\s*.+$/, '');
}
return newStr;
}
function generateInjectable() {
return degradeString(injectables[getRandomInt(0, injectables.length)]);
}
function fillWidth(str) {
var width = process.stdout.columns;
var pads = width - (str.length % width);
for (var i = 0; i < pads; i++) {
str += ' ';
}
return str;
}
function rollLines(lines) {
var count = 0;
for (var i = 0, len = lines.length; i < len; i++) {
var delay = 0;
if (Math.random() > 0.5) {
delay = getRandomInt(0, 200);
}
count += delay;
setTimeout(console.log.bind(console,
"\x1b[38;5;214;48;5;130m" + lines[i] + "\x1b[0m"), count);
}
setTimeout(outputChunk, count + getRandomInt(500, 900));
}
function outputChunk() {
var out = '';
for (var j = 0, len = getRandomInt(1, 10); j < len; j++) {
var rands = getRandomInt(30, 80);
for (var i = 0; i < rands; i++) {
out += generateRandomChar(chars, 1);
}
out += generateInjectable();
}
// Fill to width
var lines = out.split(/\n+/g);
for (var i = 0, len = lines.length; i < len; i++) {
lines[i] = fillWidth(lines[i]);
}
rollLines(lines);
}
outputChunk();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment