Bad JavaScript Poem
with (self) with (Math){ typeof self
with (window) with (sin) if (true) self }
This could be dangerous. Bad js poetry:
With self With Math Type of self With window With sin If true self
:/
with (self) with (Math){ typeof self
with (window) with (sin) if (true) self }
This could be dangerous. Bad js poetry:
With self With Math Type of self With window With sin If true self
:/
if (window . i) {
if (window . you) {
if (window . we) {
with (window . blue) {
for ( window . what in window . how ) {
for ( window . how in window . who ) {
do {} while (true)
}
}
}
}
}
}
Bad js poem:
if window i if window you if window we with window blue for window what in window how for window how in window who do while true
const { random, round } = Math
const TICK = 100
const CHUNKS_PER_TICK = 4
const minChunk = 3
const maxChunk = 10
const diffChunk = maxChunk - minChunk
const generateChance = .9 // 90% change of string generation
const spaceChance = .8 // 80% chance of space
const breakChance = .1 // 10% chance of line break
const numbersChance = .9
const randomChunk = () => round(random() * 0xff).toString(36)
.replace(random() < numbersChance ? /[0-9]/g : '', '')
setInterval(() => {
if (random() < generateChance) {
Array(CHUNKS_PER_TICK).fill(0).forEach(() => {
const stringLeng = round(minChunk + random() * diffChunk)
let chunk = ''
Array(stringLeng).fill(0)
.forEach(() => chunk += randomChunk())
const span = document.createElement('span')
const hue = round(random() * 360)
span.style.color = `hsl(${hue}, 30%, 50%)`
document.body.appendChild(span)
span.innerText = chunk
if (random() < spaceChance) {
document.body.appendChild(document.createTextNode(' '))
}
if (random() < breakChance) {
const br = document.createElement('br')
document.body.appendChild(br)
}
})
}
scrollTo(0, document.body.scrollHeight)
}, TICK)
// just a lazy hack since snippet zone quick editor only supports js...
// normally this goes in a separate file... :D
document.body.innerHTML += `
<style>
body, html {
background: black;
font-family: Oswald, sans-serif;
overflow-wrap: break-word;
text-transform: uppercase;
letter-spacing: 1;
}
br {
height: 1em;
display: block;
}
</style>
`
An expansion on a snippet from a few days ago inspired by a friends codepen fork…
<!-- from w3schools.com -->
<!DOCTYPE html>
<html>
<body>
<h1>The output element</h1>
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">
<input type="range" id="a" value="50">
+<input type="number" id="b" value="25">
=<output name="x" for="a b"></output>
</form>
<p><strong>Note:</strong> The output element is not supported in Edge 12 (or earlier).</p>
</body>
</html>
I like w3Schools.
This code has some problems… but… for a cool little snippet to play with – I think that’s ok. SnippetZone certainly has tons of things like this…
const spec = {
get(o, key) {
return o[key] != null ?
o[key] : o[key] = Objector()
}
};
const Objector = () => new Proxy({}, spec);
const events = Objector();
events.graphics.RENDERED;
events.graphics.ERASED;
events.ui.LOADING;
events.ui.LOADED;
events.files.OPENED;
events.files.CLOSED;
const { ERASED } = events.graphics;
console.log('a', ERASED === events.graphics.ERASED);
console.log('b', ERASED === events.files.CLOSED);
This is somewhat evil… I’ve never liked these java style constants. Maybe I’ll write up a detailed alternative method some time.