Skip to content

Instantly share code, notes, and snippets.

@SourceCode
Created January 8, 2023 02:34
Show Gist options
  • Save SourceCode/be84d56dfb210a03dc46258ed494e20f to your computer and use it in GitHub Desktop.
Save SourceCode/be84d56dfb210a03dc46258ed494e20f to your computer and use it in GitHub Desktop.
Render binary time representation into the chrome console
// Use in chrome console
function RenderBinary() {
const zeroChar = '🟢';
const oneChar = '🟠';
let frameNum = 0;
let pos = 0;
let timeStr = '';
let date = new Date();
let hours = date.getHours();
let minutes = date.getMinutes();
let seconds = date.getSeconds();
timeStr += (hours >>> 0).toString(2).padStart(4, '0');
timeStr += (minutes >>> 0).toString(2).padStart(6, '0');
timeStr += (seconds >>> 0).toString(2).padStart(6, '0');
let interval = setInterval(() => {
frameNum = (frameNum + 1) % 2;
console.clear();
let output = '';
for (let i = 0; i < 16; i++) {
for (let j = 0; j < 16; j++) {
if (timeStr[(i * 16 + j + pos) % timeStr.length] === '0') {
output += zeroChar;
} else {
output += oneChar;
}
}
output += '\n';
}
console.log(output);
pos++;
if (pos >= timeStr.length) {
pos = 0;
}
}, 250);
}
RenderBinary();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment