Skip to content

Instantly share code, notes, and snippets.

@meta-meta
Created April 23, 2017 21:38
Show Gist options
  • Save meta-meta/665d3f27d00d23573057781a12282519 to your computer and use it in GitHub Desktop.
Save meta-meta/665d3f27d00d23573057781a12282519 to your computer and use it in GitHub Desktop.
Atom chaos nullspace
// var str = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890~!@#$%^*()-_=+,./<>?;:\'"[]{}|`&';
var str = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890';
var randChar = () => str.substr(Math.floor(Math.random() * str.length), 1)
// this one works better. I think maybe the random chars are being parsed to some degree so they don't fill the space??
var randStr = len => new Array(len)
.fill('')
.map(randChar)
.join('');
var editor = atom.workspace.getActiveTextEditor();
var getNullLength = (line) => editor.getMaxScreenLineLength() - line.textContent.length;
var fillLine = line => {
var noise = line.querySelector('.noise');
if(noise) {
noise.textContent = randStr(noise.textContent.length);
} else {
line.insertAdjacentHTML('beforeEnd', `<span class="noise">${randStr(getNullLength(line))}</span>`)
}
};
var interval = setInterval(() => document.querySelectorAll('.line').forEach(fillLine), 20);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment